...

/

Using Different Configuration Settings in Production

Using Different Configuration Settings in Production

Let's create a new .ini file to emulate the production environment and learn how to catch exceptions.

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.

Press + to interact
; Show no errors in the response body
display_errors = Off

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:

Press + to interact
php -c php.ini -c php-prod.ini -i

This produces a lot of output, but we can use grep ...

Access this course and 1400+ top-rated courses and projects.