如何更改 Laravel 4 中的错误报告级别?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/18616367/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 08:22:43  来源:igfitidea点击:

How to change error reporting level in Laravel 4?

phplaravellaravel-4error-reporting

提问by brazorf

How can i change the PHP error_reporting in L4?

如何更改 L4 中的 PHP error_reporting?

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.

我找到了这个http://forums.laravel.io/viewtopic.php?id=6072,但它是关于 L3 的,我不知道如何实现同样的目标,即防止应用程序在 php E_NOTICE 上抛出异常.

回答by Rob Gordijn

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.

用户“你的常识”(顺便说一句很棒的名字)是正确的修复错误。欢迎来到 2013 年,“未定义索引错误”已成为过去式。

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.phpthe 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

在该文件vendor/laravel/framework/src/Illuminate/Foundation/start.phperror_reporting()设置为-1,又名:“报告中的所有错误。” 尝试更改error_reporting的级别,链接到手册:http: //php.net/manual/en/function.error-reporting.php

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

global.php在 /app 目录中编辑您的,并在底部添加: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.

[编辑] 顺便说一句:在 app/config/app.php (或 app/config/-environment-/app.php 中,您可以将调试更改为 false。这样您的应用程序的用户就不会收到任何技术错误-消息。

回答by Webby

Just set error reporting 0 in app\start\global.php in the top of the page.

只需在页面顶部的 app\start\global.php 中设置错误报告 0 即可。

error_reporting(0);

回答by Your Common Sense

Citing from the forum you linked to:

引用您链接到的论坛:

now you should know as a programmer you need to fix the error and not hide it.

现在,作为程序员,您应该知道您需要修复错误而不是隐藏它。