In Laravel 4, it was easy enough to suppress E_NOTICE messages; I can't seem to be able to do this because if I add
error_reporting(E_ALL ^ E_NOTICE)
anywhere it simply gets overridden.
This seems to happen around here: (index.php)
$response = $kernel->handle(
$request = Illuminate\Http\Request::capture()
);
I have added custom code to handle more "pretty" views of exceptions/errors within Exceptions/Handler.php but I'm struggling to switch off notices (I don't want any of these firing off with notices at all)
By default, error detail is enabled for your application. This means that when an error occurs you will be shown an error page with a detailed stack trace and error message. You may turn off error details by setting the debug option in your app/config/app. php file to false .
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-depth With the error_reporting() functionerror_reporting(0); To remove all errors, warnings, parse messages, and notices, the parameter that should be passed to the error_reporting function is zero. It would be not practical to have this line of code in each of the PHP files.
When you start a new Laravel project, error and exception handling is already configured for you. The App\Exceptions\Handler class is where all exceptions thrown by your application are logged and then rendered to the user.
In Laravel 5, we can set error_reporting(E_ALL ^ E_NOTICE)
inside the AppServiceProviders::boot
method:
public function boot()
{
//set whatever level you want
error_reporting(E_ALL ^ E_NOTICE);
}
Are you sure APP_DEBUG
in your .env
file is set to false in production? That might override your error_reporting()
call.
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