Currently an environment variable can be specified in the php.ini file. This is useful if you want tune one or two settings in your runtime environment. Where this runs into issues is if you want to do something similar to Juan Terminio[1][2].
I'm proposing a change the php.ini parser that would allow for an extended syntax for environment variables in the php.ini. In this syntax when checking for an environment variable if it is empty the fallback value would be used instead. The original environment variable syntax would remain valid as well. Possible syntax options. I currently do not have a very deep understanding of the current .ini parser so this may make invalid assumptions. * memory_limit = ${PHP_MEMORY_LIMIT:-"default value"} * memory_limit = ${PHP_MEMORY_LIMIT::"default value"} * memory_limit = ${PHP_MEMORY_LIMIT:="default value"} * memory_limit = ${PHP_MEMORY_LIMIT=="default value"} * Potential issue: Adopting a bash-ism This type of environment fallback is common in bash. If adopted it could lead users to think other bash features are also available. To dissuade this I would suggest that the fallback value syntax not appear in any of the default php.ini files. Users must read the documentation and decide if it works for them and add it in their php.ini file. Changes needed in the code Digging through the code I find that two sections would need to be changed, both in Zend/zend_ini_parser.y. I hope to be able to write this code myself but would gladly accept some guidance. 1. cfg_var_ref: Currently TC_DOLLAR_CURLY TC_VARNAME '} would need to be changed to something like TC_DOLLAR_CURLY TC_VARNAME ':-' TC_FALLBACK '}' 2. zend_ini_get_var: I imagine this would require adding a third parameter to the function signature that would be used in the event of a null value when checking the environment. [1] https://jtreminio.com/blog/php-modules-toggled-via-environment-variables/ [2] https://jtreminio.com/blog/docker-php/php-fpm-configuration-via-environment-variables/ I look forward to your feedback. Derek