Skip to content

Instantly share code, notes, and snippets.

@bastman
Created November 20, 2012 15:29
Show Gist options
  • Save bastman/4118614 to your computer and use it in GitHub Desktop.
Save bastman/4118614 to your computer and use it in GitHub Desktop.
PHP Symfony2 ErrorHandler Example
<?php
/**
* Created by JetBrains PhpStorm.
* User: seb
* Date: 11/20/12
* Time: 4:10 PM
* To change this template use File | Settings | File Templates.
*/
require dirname(__FILE__).'/ErrorHandler.php';
use Symfony\Component\HttpKernel\Debug\ErrorHandler;
ini_set('display_errors', false);
error_reporting(E_ALL|E_STRICT);
$captureLevel = null; // any capture level
$captureLevel = error_reporting(); // current capture level
//$captureLevel = (E_ALL | E_STRICT) ^ E_NOTICE; // ignore notices. I HATE DOING SO!
ErrorHandler::register($captureLevel);
try {
// this crappy code
// will trigger notices ...
var_dump(__FILE__);
$arr =array();
@include 'foo.php';
var_dump(@$arr[0]);
var_dump($arr[0]);
}catch (\Exception $e) {
var_dump('EXCEPTION CATCHED IN '.__FILE__);
var_dump($e);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment