Is there a best practice for managing php.ini configurations from development to production? Obviously it can be done manually, but that is prone to human error. I'd like to try and have the production file in version control and then possibly modify the development version automatically.
Thoughts or ideas i've had which i dont know if they are feasible:
- php.ini includes - just include the dev settings at the end of
the file?
- conditional loads from apache conf?
- write a script that when php.ini changes, a dynamic version of phpdev.ini gets generated - (i know this can be done)
- use runtime php settings for display errors - i think this has limitations because if the script has fatal errors, then it wont run the runtime setting.
- backup plan - keep the production version in SC, and manually change
phpdev.ini as needed as needed. Then if manual mistakes are made
they are done at the development level.
- Store your ini in your source code repository in different directories named after their environments: environments/{dev,qa,staging,prod}/php.ini
- On each environment, do this:
rm /etc/php.ini; ln -s /var/www/site/environments/prod/php.ini /etc/php.ini
This way, you get the benefits of revision control and don't necessarily have to edit each manually.
I don't know exactly if this is what you're looking for, but personally I like to perform all non-security-necessary php.ini modifications via the apache virtualhost settings, e.g. a development virtualhost:
ServerName sb.local
ServerAlias sb.local
DocumentRoot /srv/some-site
php_value session.cookie_domain "sb.local"
php_value date.timezone "America/New_York"
php_value mbstring.func_overload 7
php_value default_charset "utf-8"
AddDefaultCharset utf-8
php_value session.gc_maxlifetime "990000"
php_value error_reporting 30711
# 30711 = E_ALL ^ E_NOTICE
php_value display_errors "On"
php_value display_startup_errors "On"
php_value log_errors "On"
php_value html_errors "On"
etc