alexmasterov / twig-extension
A collection of custom extensions for the Twig template engine
0.4.0
2016-09-24 23:13 UTC
Requires
- php: ^5.4 || ^7.0
- psr/http-message: ^1.0
- twig/twig: ^1.25 || ^2.0
This package is not auto-updated.
Last update: 2024-12-17 17:52:55 UTC
README
A collection of custom extensions for the Twig template engine.
Extensions
Psr7UriExtension
— provides useful functions using PSR-7 HTTP message interface.
Installation
The suggested installation method is via composer:
composer require alexmasterov/twig-extension
Configuration
To activate an extension you need to register it into the Twig environment:
/* * @var $twig Twig_Environment * @var $request ServerRequestInterface */ $twig->addExtension( new AlexMasterov\TwigExtension\Psr7UriExtension(ServerRequestInterface $request) );
The example of registering the extension using Auryn and Diactoros:
$injector = new Auryn\Injector; $injector->alias( Psr\Http\Message\ServerRequestInterface::class, Zend\Diactoros\ServerRequest::class ); /* * @var $twig Twig_Environment */ $twig->addExtension( $injector->make(AlexMasterov\TwigExtension\Psr7UriExtension::class) );