Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Start a free Courses trial
to watch this video
When possible, it's usually best to modify the php.ini file on your webserver. This will allow you to turn on all errors and display in development, while locking down the display of errors on production. Using the php.ini file will also allow you to see parse errors that will stop a php script from processing.
The php.ini
file, as mentioned in Before You Start, is only applicable for locally hosted servers or a hosting server you have access to. If you'd like to follow along, make sure that you are developing using a local PHP Dev Environment.
Modify you php.ini file
- While your server is running, go to the phpinfo file in a browser I'm using http://localhost/phpinfo.php
-
Search for βphp.iniβ. You should see something like βConfiguration File (php.ini) Pathβ. Examples:
MAC /Applications/MAMP/bin/php/php7.0.0/conf
Windows C:\MAMP\conf\php7.0
-
You can open the php.ini file in a text editor or in a terminal. Copy the path and open a terminal window.
MAC: Type sudo vi and then paste the path with php.ini at the endsudo vi /Applications/MAMP/bin/php/php7.0.0/conf/php.ini W
Windows: Open notepad first then choose File > Open or copy the path and open a terminal window, examplenotepad C:\MAMP\conf\php7.0\php.ini
-
Search for error_reporting:
MAC: Type a forward slash to search /error_reporting
Windows: Edit > Find, error_reporting
- error_reporting: Set the error reporting level. The default value is: βE_ALL & ~E_NOTICE,β meaning this this would should all error levels except E_NOTICE. For a development server you probably want to turn everything on by just using E_ALL.
- display_errors: Set it to βONβ (default is βOFFβ)if errors are to be printed to the screen.
- log_errors: This indicates whether or not error logging should be done; default value is βon.β
- error_log string: Sets the name of the file where script errors should be logged
-
There are a couple additional settings that will give you more information or control.
- display_startup_errors: For debugging, you can also turn on errors that occur during PHP's startup sequence
- html_errors: You can also control HOW your errors as displayed. The new format for HTML errors produces clickable messages that direct the user to a page describing the error, or function causing the error. This is on by default but you can turn it off
After saving the file, you must restart the servers for the changes to take affect.
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign upRelated Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up