1000 FAQs, 500 tutorials and explanatory videos. Here, there are only solutions!
Configure the PHP parameters via CLI
This guide explains how to configure the PHP parameters of Web hostings directly from the command line when you run PHP scripts using PHP CLI (Command Line Interface).
Preamble
- This type of configuration can be useful when you need to temporarily modify certain parameters for a specific script or for a PHP session.
- These changes will only be valid for the current script execution and will not alter the global PHP configuration.
Modify the PHP CLI parameters
For example, to temporarily modify the parameters for a specific script without having to modify the configuration PHP of the server, follow the method below; with the PHP CLI environment you can specify multiple PHP parameters at the same time by separating them with spaces.
Using the parameter -d
When you run PHP from the command line, you can use the parameter -d
to specify PHP configurations. This allows you to modify the PHP parameters for that specific execution. For example, to set the maximum execution time to 90 seconds, the memory limit to 256 MB and disable secure mode, you can do it as follows:
php -d max_execution_time=90 -d memory_limit=256M -d safe_mode=Off -f test.php