How to change error reporting level in Laravel 4?

brazorf picture brazorf · Sep 4, 2013 · Viewed 9k times · Source

How can i change the PHP error_reporting in L4?

I found this http://forums.laravel.io/viewtopic.php?id=6072, but it's about L3 and i can't figure out how to achieve that same goal, that is prevent the application from throwing exception on php E_NOTICE.

Answer

Rob Gordijn picture Rob Gordijn · Sep 4, 2013

User "your common sense" (awesome name btw) is right about fixing the error. Welcome in 2013, the 'undefined index error' is a thing from the past these days.

Except if you are working with legacy code which can't be altered that simple... So here we go:

In the file vendor/laravel/framework/src/Illuminate/Foundation/start.php the error_reporting() is set to -1, aka: "report ALL the errors". Try to change the level of error_reporting, link to manual: http://php.net/manual/en/function.error-reporting.php

Edit your global.php in the /app directory, and add at the bottom: error_reporting(E_ERROR | E_WARNING | E_PARSE);

Undefined index errors wont show anymore. Feel free to adjust the level to your needs.

[edit] Ow by the way: in app/config/app.php (or app/config/-environment-/app.php you can alter the debug to false. In this way the user of your app wont getting any technical error-messages.