k-ko / slim-twig-flash
A Twig 3 extension to access Slim Flash messages in templates
2.0.0
2021-10-16 18:22 UTC
Requires
- php: >=7.2
- slim/flash: 0.4.0
- twig/twig: ^1.34.0 || ^2.4.0 || ^3.0.0
Requires (Dev)
- friendsofphp/php-cs-fixer: 1.*
- phpunit/phpcov: ^3
- phpunit/phpunit: ^5
- satooshi/php-coveralls: ^1.0
README
A Twig 3 extension to access Slim Flash messages in templates.
Install
Via Composer
composer require k-ko/slim-twig-flash
Requires:
- PHP 7.2 or newer
- Slim Framework Flash Messages 0.1.0 or newer
- Twig 3 or newer
Usage
- Add extension to your twig view
... $view->addExtension(new Knlv\Slim\Views\TwigMessages( new Slim\Flash\Messages() )); ...
- In templates use
flash()
orflash('some_key')
to fetch messages from Flash service
... <ul class="alert alert-danger"> {% for msg in flash('error') %} <li>{{ msg }}</li> {% endfor %} </ul> ...
Testing
phpunit
License
The GNU GENERAL PUBLIC LICENSE Version 3. Please see License File for more information.