Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change error reporting level in Laravel 4?

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.

like image 622
brazorf Avatar asked Sep 04 '13 14:09

brazorf


People also ask

How do I turn on error reporting in laravel?

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.

How do I disable error reporting in laravel?

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 .

How do I turn off error reporting in PHP?

To turn off or disable error reporting in PHP, set the value to zero. For example, use the code snippet: <? php error_reporting(0); ?>


1 Answers

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.

like image 74
Rob Gordijn Avatar answered Sep 21 '22 11:09

Rob Gordijn