MAMP, PHP5, CakePHP, and Strict Standards

We’re making the move to PHP5 for our latest project, and it was much to my dismay when I saw a series of errors unleashed during the first test of the Cake pre-beta:



Strict Standards: Assigning the return value of new by reference is deprecated in /Applications/MAMP/htdocs/xxxx/cake/basics.php on line 279

Strict Standards: Redefining already defined constructor for class Object in /Applications/MAMP/htdocs/xxxx/cake/libs/object.php on line 65

Strict Standards: Assigning the return value of new by reference is deprecated in /Applications/MAMP/htdocs/xxxx/cake/libs/object.php on line 92

Strict Standards: Assigning the return value of new by reference is deprecated in /Applications/MAMP/htdocs/xxxx/cake/libs/inflector.php on line 65

Strict Standards: Assigning the return value of new by reference is deprecated in /Applications/MAMP/htdocs/xxxx/cake/libs/configure.php on line 96

Strict Standards: Assigning the return value of new by reference is deprecated in /Applications/MAMP/htdocs/xxxx/cake/libs/configure.php on line 154

Strict Standards: Assigning the return value of new by reference is deprecated in /Applications/MAMP/htdocs/xxxx/cake/libs/cache.php on line 71

Strict Standards: Assigning the return value of new by reference is deprecated in /Applications/MAMP/htdocs/xxxx/cake/libs/cache.php on line 157

Strict Standards: Non-static method Configure::getInstance() should not be called statically in /Applications/MAMP/htdocs/xxxx/cake/bootstrap.php on line 48

Now I know that this wasn’t Cake’s problem. This is PHP5’s new error reporting standard, which was turned on for some reason.

To disable Strict Error Reporting, edit your php.ini file and set the error_reporting to (line 270):


error_reporting  =  E_ALL & ~E_STRICT

Or, in your .htaccess file in your root cake installation, you can add the following line:


php_value error_reporting 6143

Which is the bit value of E_ALL & ~E_STRICT.

Either way, the errors should disappear. The reason they exist in the first place? According to Gwoo, it’s to maintain Cake’s functionality with PHP4.

If you’re still confused, you can always visit PHP’s page on error reporting for more on error-lovin’.