2013-06-19 74 views
1

因爲我更新了我的項目到Symfony 2.3 php通知不再拋出異常。拋出異常與使用Symfony 2.3的php通知

我可以嘗試訪問數組中的未定義索引,並顯示通知,但不會引發異常。

起初,我想我很困惑,也許這是前面的版本的行爲。我在stackoverflow上發現了一些其他方面的問題。

how to handle PHP notice in symfony2

反正是有作出Symfony2的通知Symfony的2.3拋出異常?

回答

2

Have a look在FrameworkBundle的boot()方法的開頭:

public function boot() 
{ 
    ErrorHandler::register(null, false)->throwAt($this->container->getParameter('debug.error_handler.throw_at'), true); 
    // ... 
} 

即使你註冊在AppKernel自己的錯誤處理(如我在做),該FrameworkBundle覆蓋它。但是你可以使用debug.error_handler.throw_at參數配置FrameworkBundle的錯誤處理程序,就像這樣:

# in config.yml, for example 
parameters: 
    # ALWAYS throw exceptions for notices, warnings, etc. 
    debug.error_handler.throw_at: -1 

我不知道,這是在任何地方記錄。

由於PHP的注意事項和警告通常表明有嚴重的編程錯誤(d'oh!),所以即使在生產環境中,我也總是會拋出異常。