Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MAMP Config help, display PHP errors

Tags:

php

apache

mamp

I am running the latest version of MAMP on Snow Leopard.

My php.ini file has been configured to display errors. display_errors = on. The phpinfo(); page displays the status of error reporting, it is on. I have restarted my web server several times.

I've searched through Google, and I cannot find any similar problem. Everyone just says to do exactly what I have done, but it is not working. The pages will just remain blank, (with no reporting), if I intentionally place errors.

Any thoughts as to what the problem may be?

like image 327
Jonathan Musso Avatar asked Feb 19 '10 15:02

Jonathan Musso


People also ask

How do I check the error log in MAMP?

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

How do I enable PHP warnings?

The quickest way to display all php errors and warnings is to add these lines to your PHP code file: ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(E_ALL);


2 Answers

For any future posters who run into this issue...

I was having the same issue and found that I was making changes to the wrong php.ini files. Run phpinfo and find the path to the active php.ini file to make sure you're editing the correct one.

On my installation of mamp there were multiple instances of the /conf directory with php.ini files. The php.ini files I needed were located in the /bin/php/php[version#]/conf directory and not the MAMP/conf directory.

Exact path to the php.ini file I needed to edit:

Applications/MAMP/bin/php/php5.4.10/conf/php.ini

Change display_errors = Off to display_errors = On

like image 108
Mikael Kessler Avatar answered Sep 18 '22 16:09

Mikael Kessler


In addition to the display_errors directive, which has to be set to On, you might have to configure error_reporting.

For instance, you can use this in your php.ini file :

error_reporting = E_ALL


Another should, useful to test, might be to place this kind of portion of PHP code at the beginning of your script :

error_reporting(E_ALL);
ini_set('display_errors', 'On');

This is useful when you don't have access to php.ini and/or just want to test quickly, without having to restart the webserver.


As a sidenote, when it comes to displaying errors, the Xdebug extension is really great : when it's installed/enabled/configured, instead of just having an error message, you'll get the full stack-trace, which is much more useful ;-)

like image 34
Pascal MARTIN Avatar answered Sep 18 '22 16:09

Pascal MARTIN