Created
September 27, 2011 08:19
-
-
Save makasim/1244593 to your computer and use it in GitHub Desktop.
Symfony2 + UniversalErrorHandler
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use Symfony\Component\HttpKernel\Kernel; | |
use Symfony\Component\HttpKernel\Debug\ExceptionHandler; | |
use UniversalErrorCatcher_Catcher; | |
class AppKernel extends Kernel | |
{ | |
public function init() | |
{ | |
$debug = $this->debug; | |
ini_set('display_errors', 0); | |
if ($this->debug) { | |
error_reporting(-1); | |
} | |
$catcher = new UniversalErrorCatcher_Catcher(); | |
$catcher->setThrowRecoverableErrors(true); | |
$catcher->registerCallback(function(\Exception $e) use($debug) { | |
if ('cli' !== php_sapi_name()) { | |
$handler = new ExceptionHandler($debug); | |
$handler->handle($e); | |
} | |
}); | |
$catcher->start(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment