How to show PHP Error and review Error Logs from MAMP on your Mac (or PC)

If you are using MAMP for local development, you may be a bit frustrated as it won’t report errors on the webpage by default. In order to review errors, you need to open a file named php_error.log

The file, on Mac, is located in Applications > MAMP > logs > php_error.log

When you double click on it, the file will open automatically in the Console app. You can click on “Now” on the toolbar of the app to keep the log scrolling as new messages appear. I also like to click on “Clear” so that I can easily spot new errors and warnings that get generated from the moment I start testing the new features.

If you want errors to also show up on the webpage, you will need to edit php.ini, which is located in Applications > MAMP > bin > php > php[VERSION] > conf > php.ini

To see what version of PHP you currently are using in MAMP, go to MAMP > Preferences and click on PHP. The Standard version is currently 7.0.15. You can also get a full path to your currently active php.ini file by opening your MAMP start page and clicking on phpInfo on the top navigation bar. It will be listed as the “Loaded Configuration File”.

Once you locate php.ini, you can open it with your favorite text editor. I personally like Sublime Text for these quick tasks.

Search for “Error handling and logging” and take a look at the text there. It lists all possible options for the parameter error_reporting.

If you are here to make errors show up on the page in your browser, be sure to change the next parameter: display_errors = On

Here are the three php values involved into this task and how to set them up to report all errors in your browser as you load a PHP page:

error_reporting = E_ALL
display_errors = On
display_startup_errors = On