kurl / silex-error-template-provider
Error templates for silex
Installs: 199
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Type:project
Requires
- php: >=5.3.3
Requires (Dev)
- phpunit/phpunit: ~4.4
- silex/silex: ~1.2
- symfony/browser-kit: ~2.3
- symfony/css-selector: ~2.3
- symfony/twig-bridge: ~2.3
This package is auto-updated.
Last update: 2020-03-23 10:23:44 UTC
README
Version: 0.1.0
A Silex error provider copied almost verbatim from the example in the Silex Skeleton.
Usage
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.
Example
<?php $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; })); $app->register();
The default template suffix .html.twig
can be overridden by setting the kurl.error.template_suffix
value;
<?php $app['kurl.error.template_suffix'] = '.html';
Extending/customising
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.