沃梦达 / 编程问答 / php问题 / 正文

Laravel 5 错误报告抑制

Laravel 5 Error Reporting Suppression(Laravel 5 错误报告抑制)

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

问题描述

在 Laravel 4 中,很容易抑制 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.

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

This seems to happen around here: (index.php)

$response = $kernel->handle(
    $request = IlluminateHttpRequest::capture()

);

我在 Exceptions/Handler.php 中添加了自定义代码来处理更多漂亮"的异常/错误视图,但我正在努力关闭通知(我根本不希望这些中的任何一个被通知触发)

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.

推荐答案

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

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 错误报告抑制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:Laravel 5 错误报告抑制

基础教程推荐