This package is abandoned and no longer maintained. No replacement package was suggested.

Error templates for silex

0.1.0 2015-03-11 12:42 UTC

This package is auto-updated.

Last update: 2020-03-23 10:23:44 UTC


Version: 0.1.0

A Silex error provider copied almost verbatim from the example in the Silex Skeleton.


The example templates rely on a layout twig file names layout.html.twig, to use these default files this template must exist somewhere in the twig path.



$app = new Silex\Application();
$app->register(new Silex\Provider\TwigServiceProvider());
$app['twig'] = $app->share($app->extend('twig', function ($twig, $app) {
    $path = __DIR__ . '/../vendor/kurl/silex-error-template-provider';
    $twig['path'] = array(
        $path . '/src/Resources/views' // The path to the default error templates
        $path . '/tests/Fixture/example' // The path to the example layout.html.twig
    return $twig;


The default template suffix .html.twig can be overridden by setting the kurl.error.template_suffix value;


$app['kurl.error.template_suffix'] = '.html';


To provide customised templates for specific error codes extra templates can be created in the fashion error/{code}.{suffix} in the twig path.

If a custom template was required for all 41x errors then all that is required is a template named error/41x.{suffix} in the twig path.

To use a different set of templates to those supplied simply copy the contents of the src/Resources/views/error directory to new sub directory also named error and add that new directory to the twig path either before or instead of the default path and make any modifications required to the new templates.