I\'m trying to work out the best way of handling custom error pages within Symfony2.This includes 500 and 404\'s etc.
I can create my own custom templates (error404
You should add into yours Listener
/**
*
* @var ContainerInterface
*/
private $container;
function __construct($container) {
$this->container = $container;
}
How do you register your Listener? You should register Listener like Service
Like that
core.exceptlistener:
class: %core.exceptlistener.class%
arguments: [@service_container]
tags:
- { name: kernel.event_listener, event: kernel.exception, method: onKernelException, priority: 200 }
The best way is don't use service_container. The best way is register only necessary services.
Like that
/**
*
* @var Twig_Environment
*/
private $twig;
function __construct($twig) {
$this->twig = $twig;
}