Turn off notices in cakePHP

17.5k Views Asked by At

I am new with cakePHP. I facing issue with notice on live server. I want to suppress or turn off these notices. I have tried adding,

error_reporting(E_ALL ^ E_NOTICE ^ E_WARNING ^ E_DEPRECATED);

in the index.php file in main folder. Also added same in bootstrap.php file but no luck. Can anybody suggest me how I can do this.

5

There are 5 best solutions below

0
On

Open config/core.php

  • 0: No error messages, errors, or warnings shown. Flash messages redirect. *
  • Development Mode:
  • 1: Errors and warnings shown, model caches refreshed, flash messages halted.
  • 2: As in 1, but also with full debug messages and SQL output.

seach this

Configure::write('debug', 0);
0
On

You can disable the debug feature by turning debug to 0 in the app\Config\core.php file

Configure::write('debug', 0);

If still you get the same issue so please check your live server Php version and also check the same on development server, I think there is php version compatibility issue so please see link http://bakery.cakephp.org/articles/markstory/2013/07/05/cakephp_2_3_7_2_4_0-beta_released

Hope it should work for you.

1
On

In the core.php file in /app/config, find this line and edit the level of errors you want to show: Configure::write('Error', array( 'handler' => 'ErrorHandler::handleError', 'level' => E_ALL & ~E_DEPRECATED, 'trace' => true ));

You may now add or remove the error levels as given on this page: http://php.net/manual/en/function.error-reporting.php

1
On

You are getting warnings and notice just because your DEBUG is TRUE. to solve this probem.

Go to config/app.php and just change true to false as done below..

Find this line

'debug' => filter_var(env('DEBUG', true), FILTER_VALIDATE_BOOLEAN),

And change above line to

'debug' => filter_var(env('DEBUG', false), FILTER_VALIDATE_BOOLEAN),
0
On

Try this in config/app.php file:

'Error' => [
        'errorLevel' => E_ALL & ~E_USER_DEPRECATED & ~E_NOTICE & ~E_WARNING,
        ......
        ......
],