Download the PHP package germania-kg/twigserviceprovider without Composer
On this page you can find all versions of the php package germania-kg/twigserviceprovider. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download germania-kg/twigserviceprovider
More information about germania-kg/twigserviceprovider
Files in germania-kg/twigserviceprovider
Package twigserviceprovider
Short Description Pimple Service Provider for Twig templating engine
License MIT
Informations about the package twigserviceprovider
Germania KG · TwigServiceProvider
Pimple Service Provider for Twig templating engine
Installation with Composer
Alternatively, add this package directly to your composer.json:
The v2 release requires PHP 7.3+ and Twig from v2 and up.
Setup
Have your Pimple dependency container at hand and register the TwigServiceProvider:
Usage
Once you've registered the TwigServiceProvider, you can grab and use your Twig_Environment like this:
From v2 of this package, with Twig v2 and up, this is also possible:
…There are more services, see Services section
Configuration
The default options
You can refine these options by either passing those you like to override to the constructor or extending the Twig.Config
service at runtime:
Override on instantiation
Override at runtime
Other Services
Twig.Options
Per default, the Twig_Environment instance is built with the “most important” options defined configuration—see Configuration section.. You may add other options, like so:
Twig.CachePath
Twig.TemplatePaths
Twig.Loaders
This service per default contains only the Twig_Loader_Filesystem instance;
To add one or more others, add them to the $loaders
array:
All loaders in $loaders
will automatically be chained via Twig's Twig_Loader_Chain.
See Twig developer docs for full description.
Other services
All these services return an (empty) array you may extend with custom data. They all will be added into the Twig_Environment.
Development
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: