How can I make Laravel 4 or 5 ignore PHP notices (like undefined variable notices) and not break the whole app only because of a simple 'undefined index or variable' PHP notice?
I could to that on Laravel 3 setting an 'ignore' array in config/error.php. But I cant find how to do that in Laravel 4 or 5.
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.
Through your config/app. php , set 'debug' => env('APP_DEBUG', false), to true . Or in a better way, check out your . env file and make sure to set the debug element to true.
In Laravel 5.1 you can add error_reporting(0)
or whatever you want into \app\Providers\AppServiceProvider.php boot() method
This behavior is due to setting error reporting to -1. This is Laravel's default behaviour - see line 14 in vendor/laravel/framework/src/illuminate/Foundation/start.php
if you're using Laravel 4, or line 29 in vendor/laravel/framework/src/illuminate/Foundation/Bootstrap/HandleExceptions.php
if you're using Laravel 5:
error_reporting(-1); // Reports everything
Laravel's error handler respects your error_reporting
level, and will ignore any errors that you tell PHP not to report. It's worth mentioning that changing the error reporting level isn't a good idea. But to override the previous instruction you can add your error reporting preferences in the app/start/global.php
(in Laravel 4) or app/bootstrap/app.php
(in Laravel 5)
error_reporting(E_ALL ^ E_NOTICE); // Ignores notices and reports all other kinds
Again this isn't a solution. It's merely what you are asking for. All and any errors, warning, notices etc. can and should be fixed.
You can see all the constants for error reporting here: http://www.php.net/manual/en/errorfunc.constants.php
You can get more information on how to use error_reporting here: http://php.net/manual/en/function.error-reporting.php
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With