Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I get MAMP to tell me what went wrong with php code?

Tags:

php

macos

mamp

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?

like image 233
Ulmer Avatar asked Dec 27 '11 05:12

Ulmer


People also ask

How do I check the error log in MAMP?

On a Mac, it's /Applications/MAMP/logs. Once you're there, look for the file called php-error: PHP error log in MAMP. Open the file and look for any lines that indicate problems.

How do I view MAMP logs?

Your log files are located in “C:\MAMP\logs”. You can access the various logs through the MAMP PRO interface.


2 Answers

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.

like image 154
Yes Barry Avatar answered Sep 20 '22 19:09

Yes Barry


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

like image 26
kris Avatar answered Sep 17 '22 19:09

kris