monkeycode / staticpageprovider
v1.0
2014-02-20 16:18 UTC
Requires
- silex/silex: ~1.1
- symfony/twig-bridge: ~2.4
- twig/twig: ~1.14
Requires (Dev)
- behat/behat: ~2.5
- behat/mink: ~1.5
- behat/mink-browserkit-driver: ~1.1
- behat/mink-extension: ~1.2
- symfony/yaml: ~2.4
This package is auto-updated.
Last update: 2024-10-28 23:11:06 UTC
README
A Silex ControllerProvider that helps reducing boilerplate code for static page configuration when building small sites with Silex and Twig.
Usage
$controllers = new StaticPageControllerProvider( [ 'home' => ['path' => '/', 'template' => 'index.html.twig'], 'about' => ['path' => '/about', 'template' => 'team.html.twig'], 'services' => ['path' => '/services', 'template' => 'services.html.twig'], 'contact' => ['path' => '/getintouch', 'template' => 'contact.html.twig'] ] );
Cache Headers
The options accepted by Symfony's Response::setCache()
method can be
configured as a second argument, and will be used for all registered pages:
$controllers = new StaticPageControllerProvider( [ 'home' => ['path' => '/', 'template' => 'index.html.twig'] ], ['s_maxage' => 3600] );
Content Type
An optional type
parameter can be used to set the response content type:
$controllers = new StaticPageControllerProvider([ 'descr' => [ 'path' => '/descr', 'template' => 'descr.xml.twig', 'type' => 'text/xml', ] ]);