I'm struggling to override the php cli configuration with my custom php.ini
My custom php.ini
max_execution_time = 90
memory_limit = 256M
safe_mode = Off
Running php cli
php -c /home/env/php.ini -r 'phpinfo();' | grep 'memory_limit'
outputs
memory_limit => 256M => 256M
However the custom php.ini doesn't seem to override max_execution_time nor safe_mode as it outputs 0 and On rather than 90 and Off.
Running this simple script
#!/usr/bin/php -c /home/env/php.ini
<?php echo 'memory_limit: ' . ini_get('memory_limit');
outputs the default cli configuration (128M) rather than 256M as expected.
Running this simple script
#!/usr/bin/php -d max_execution_time=90
<?php echo 'max_execution_time: ' . ini_get('max_execution_time');
outputs 90 as expected.
So far I've managed to override only one single configuration directive at runtime, so any help much appreciated how to override multiple configuration directives.
Edit:
php -a
php > parse_ini_file('/home/env/php.ini');
outputs no errors, so I guess my custom php.ini is ok. I'd though just discover that executing
#!/usr/bin/php -c /home/env/php.ini
<?php echo 'memory_limit: ' . ini_get('memory_limit'); phpinfo();
says Loaded Configuration File => (none). That seems to be the issue. PHP CLI doesn't seem to load my custom php.ini file even though the path is correct and syntax seems fine too.
Solution:
It doesn't seem possible to override multiple configuration directive at runtime with shebang, at least for me. But removing shebang and executing the following command solved the issue for me.
php -d max_execution_time=90 -d memory_limit=256M -d safe_mode=Off -f test.php