48

Whenever I have an error in my php code, MAMP just returns a 500 error. Is there anyway I can get MAMP to tell me what went wrong like parsing errors and stuff?

hakre
  • 193,403
  • 52
  • 435
  • 836
Ulmer
  • 1,530
  • 2
  • 17
  • 24
  • 1
    I figured it out i just had to change line 277 of php conf file to turn on error reporting. – Ulmer Dec 27 '11 at 05:37

3 Answers3

94

Just as you reported, you must have display_errors set to on. This can be done either by changing the conf file or by using .htaccess like so:

<IfModule mod_php5.c>
    php_flag display_errors on
</IfModule>

Additionally, you can do this with ini_set() like so:

ini_set('display_errors', 1);

One last thing, you can also check /Applications/MAMP/logs which has three different error log files.

Try opening terminal and run this command:

tail -f /Applications/MAMP/logs/php_error.log

When you want to stop "following" (the -f switch) the log file, just type control+C.

Yes Barry
  • 9,514
  • 5
  • 50
  • 69
  • 2
    In newer version of MAMP the default filename may be "phperror.log": –  Sep 27 '16 at 11:22
11

You can also access MAMP errors using the Mac "Console" app to read the php_error.log file.

I find this easiest to access by using spotlight and typing in "error.log".

enter image description here

( it won't find it if you type "php_error.log", you must type "error.log" )

It looks like this :

enter image description here

Community
  • 1
  • 1
kris
  • 11,868
  • 9
  • 88
  • 110
0

2022 update:

If we talk about usual MAMP (not PRO version), my research showed that there's no way to enable displaying of PHP errors using GUI. However, all the old approaches with configuration files mentioned in answers to this question and several others still work. But be careful with config names since they have been changing over some versions.

For MAMP PRO users: You can easily enable outputting of PHP errors using GUI:

  1. Switch to Expert view at the top left corner: screenshot
  2. Click on the PHP language: screenshot
  3. And then check the option to screen of the Log errors property: screenshot
  4. Hit Save and restart the servers when MAMP asks you to restart or not.

You're done. PHP now should output error message in the place where error occured.

Also, if you prefer configuring everything by hand, the option with configuration files works here as well.

At the time of writing this answer, the actual version of MAMP (and PRO) was 6.6.2.