Reputation: 307
After updating my MAMP PRO (on OS X Yosemite 10.10.3) to the most recent version 3.2.1 it stopped displaying errors. In MAMP PRO you can set the error displaying options in the GUI on the PHP tab. Everything has a checkbox there (it's in German, but it says something like "All errors" [checked], "Display" [checked]).
When I check with phpinfo(), display_errors
is On
and error_reporting
is 32767
(which should be equivalent to E_ALL
).
However, if I do something like array_merge(false, array())
I get no error. If I miss a semicolon (syntax errors) I get a blank page.
I tried removing MAMP PRO completely and reinstalling it multiple times, even after rebooting, to no avail. All "solutions" out there say you should put display_errrors = On
and error_reporting = E_ALL
which is what I have, also it is using the correct php.ini which I verified with phpinfo().
When I put
error_reporting(E_ALL);
ini_set('display_errors', 'On');
in my PHP code just above the error, e.g. for array_merge(false, array())
, I finally get an error message "Message: array_merge(): Argument #1 is not an array" which is what I expect, but I want to get that message without having to use ini_set in my PHP code. Also, the syntax errors are still not showing, even with this method.
I spent hours on this and would really appreciate any help to fix this.
Upvotes: 0
Views: 288
Reputation: 307
Ok, I finally figured it out. The application I was working on is using Codeigniter and in the index.php the ENVIRONMENT
constant was incorrectly set to 'production' which in turn set error_reporting to 0 like this:
case 'production':
error_reporting(0);
break;
Once I set the ENVIRONMENT
constant to 'development', it works as expected.
So why did this happen after upgrading to the latest MAMP PRO 3.2.1? The code for setting the ENVIRONMENT
constant checks if $_SERVER['SERVER_ADDR'] == '127.0.0.1'
and if true, sets the ENVIRONMENT to development:
if ($_SERVER['SERVER_ADDR'] == '127.0.0.1') {
define('ENVIRONMENT', 'development');
}
In the latest MAMP PRO, the $_SERVER['SERVER_ADDR']
is not 127.0.0.1
anymore but ::1
. The changelog for v3.2 says:
Every host gets the IPv6 entry ::1 in /etc/hosts
Pretty tricky stuff. I now use $_SERVER['HTTP_HOST']
instead of $_SERVER['SERVER_ADDR']
to set the ENVIRONMENT
constant.
Upvotes: 1