Download the PHP package germania-kg/twig-requesthandler without Composer
On this page you can find all versions of the php package germania-kg/twig-requesthandler. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download germania-kg/twig-requesthandler
More information about germania-kg/twig-requesthandler
Files in germania-kg/twig-requesthandler
Package twig-requesthandler
Short Description PSR-15 RequestHandler for rendering Twig templates
License MIT
Informations about the package twig-requesthandler
Germania KG · RequestHandler for Twig
Installation
Setup
The constructor accepts a Twig Environment and PSR-17 ResponseFactory. This example uses Tobias Nyholm's nyholm/psr7 package: composer require nyholm/psr7
Usage
Have a ServerRequest at hand and configure it with a template attribute and a context attribute.
- The template attribute must be a string as required by Twig.
- The context attribute must be an array as required by Twig; Instances of ArrayObject will be converted.
N.B. Invalid variable types will lead to a RuntimeException at runtime on request handling, not during configuration!
Now, the above RequestHandler can be used as normal:
Configuration
You can change these default settings:
You can change these default settings
… and the core components:
Issues
Development
Grab and go using one of these:
Unit tests
Either copy phpunit.xml.dist
to phpunit.xml
and adapt to your needs, or leave as is. Run PhpUnit test or composer scripts like this:
All versions of twig-requesthandler with dependencies
twig/twig Version ^2.0|^3.0
psr/http-message Version ^1.0
psr/http-server-handler Version ^1.0