Skip to content

Instantly share code, notes, and snippets.

@makasim
Created September 27, 2011 08:19
Show Gist options
  • Save makasim/1244593 to your computer and use it in GitHub Desktop.
Save makasim/1244593 to your computer and use it in GitHub Desktop.
Symfony2 + UniversalErrorHandler
<?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