Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I enable PHP errors on OSX Lion?

Tags:

php

osx-lion

wsod

I can't get my setup to display PHP errors. The only thing I see is the WSOD.

I've updated my php.ini file:

(excerpt from phpinfo())

display_errors          On      On
display_startup_errors  On      On
error_reporting         30719   30719

Any ideas?

like image 428
Yves Van Broekhoven Avatar asked Feb 07 '12 08:02

Yves Van Broekhoven


People also ask

How do I enable error messages for PHP?

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);

How do I troubleshoot PHP errors?

To view the errors in your PHP application, you will need to set the following settings in your PHP page so you can troubleshoot the problems. Knowing how to configure PHP display errors is really important. ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(E_ALL);

Where is my PHP on Mac?

Set the php. ini location or use the default A typical default location on macOS is /usr/local/php/php.

How do I turn off PHP warnings?

In the current file, search for the line of code error_reporting. There will be a line of Default Value: E_ALL as shown below: Replace this line of code with Default Value: E_ALL & ~E_NOTICE. It will display all the errors except for the notices.


1 Answers

If you're using the default installation of Apache in OSX you need to edit /etc/php.ini however if you're using a MacPorts install you will need to edit /opt/local/etc/php5/php.ini

You state your phpinfo() is showing that errors are enabled. If they are not displaying they must be being overridden.

Places to check

  • httpd.conf, httpd-vhosts.conf, and other config files in /etc/apache2/extras (not sure on MacPorts paths) - Look for php_value lines.
  • .htaccess files - Again look for php_value lines.
  • .user.ini files - PHP 5.3+ supports per directory configuration like Apache.
  • Your scripts themselves. They may implement custom error handlers that turn off error reporting with ini_set.

You can try enabling at a script level using the following:

ini_set('error_reporting', -1);
ini_set('display_errors', 1);
ini_set('html_errors', 1); // I use this because I use xdebug.

0:: // My favourite kind of error.
like image 51
Leigh Avatar answered Oct 12 '22 07:10

Leigh