Reputation: 1951
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.
Upvotes: 6
Views: 9370
Reputation: 333
Just set error reporting 0 in app\start\global.php in the top of the page.
error_reporting(0);
Upvotes: 0
Reputation: 6511
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.
Upvotes: 10
Reputation: 157828
Citing from the forum you linked to:
now you should know as a programmer you need to fix the error and not hide it.
Upvotes: -2