Laravel 5错误报告抑制 [英] Laravel 5 Error Reporting Suppression

查看:164
本文介绍了Laravel 5错误报告抑制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Laravel 4中,很容易抑制E_NOTICE消息;
我似乎无法做到这一点,因为如果我添加

  error_reporting(E_ALL ^ E_NOTICE)

任何地方只会被覆盖。



似乎在这里发生:
(index.php)

  $ response = $ kernel-> handle(
$ request = Illuminate\Http\Request :: capture()

);

我添加了自定义代码来处理异常/处理程序中更多漂亮的异常/错误视图。 php但我正在努力关闭通知(我根本不希望任何一个通知通知)




  • 是的,这个问题应该是固定的,我知道这一点,但是这样的情况下,我更喜欢没有在现场直接攻击应用程序的通知(我有一个自定义的日志记录解决方案),在开发者我想要通知。


解决方案

在Laravel 5中,我们可以在 AppServiceProviders :: boot 方法中设置 error_reporting(E_ALL ^ E_NOTICE)

  public function boot()
{
//设置任意级别
error_reporting(E_ALL ^ E_NOTICE);
}


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.

解决方案

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);
} 

这篇关于Laravel 5错误报告抑制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆