14

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)

  • Yes, the issue should be fixed, I'm aware of this, however this is a case where I'd prefer the notices NOT bombing the app on live (I have a custom logging solution for this), and on dev I'd like the notice to show.
Moppo
  • 18,797
  • 5
  • 65
  • 64

2 Answers2

12

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);
} 
Moppo
  • 18,797
  • 5
  • 65
  • 64
  • 2
    Dude, I was looking for a solution for this shit for almost the whole day. Thank you so much for this piece of gold, you saved me man! – L.Butz Nov 22 '18 at 15:16
1

Are you sure APP_DEBUG in your .env file is set to false in production? That might override your error_reporting() call.