問題描述
在 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 錯誤報告抑制的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!