Using Different Configuration Settings in Production
Explore how to manage different PHP configuration settings by using multiple .ini files for development and production environments. Understand the importance of turning off error display in production, implementing custom error pages, and setting up global exception handlers to improve your application's error handling and security.
We'll cover the following...
Using multiple .ini files
Once the website has been deployed to a production environment, the display_errors setting should be Off.
While developing locally, you can simulate this by using multiple .ini files.
The php.ini file we have been using so far will be the development version.
We will create another .ini file called php-prod.ini, which will contain settings that mimic the production environment.
When you supply multiple php.ini files using the -c command line option, PHP will merge all these configuration values.
By loading php-prod.ini last, this file’s settings will win from the settings in php.ini.
You can verify that this works by running php -i, which displays all the current PHP settings:
This produces a lot of output, but we can use grep to ...