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

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

In PHP how can you clear a WSDL cache?(在 PHP 中如何清除 WSDL 缓存?)
failed to open stream: HTTP wrapper does not support writeable connections(无法打开流:HTTP 包装器不支持可写连接)
Stop caching for PHP 5.5.3 in MAMP(在 MAMP 中停止缓存 PHP 5.5.3)
Caching HTTP responses when they are dynamically created by PHP(缓存由 PHP 动态创建的 HTTP 响应)
Memcached vs APC which one should I choose?(Memcached 与 APC 我应该选择哪一个?)
What is causing quot;Unable to allocate memory for poolquot; in PHP?(是什么导致“无法为池分配内存?在 PHP 中?)