glazilla / slim-twig-flash
A Twig extension to access Slim Flash messages in templates
v1.0
2022-11-10 11:59 UTC
Requires
- php: >=7.4.0
- slim/flash: ^0.4
- twig/twig: ^3.4.3
Requires (Dev)
- friendsofphp/php-cs-fixer: 1.*
- phpunit/phpcov: 2.*
- phpunit/phpunit: 4.8.0
- satooshi/php-coveralls: dev-master
This package is auto-updated.
Last update: 2024-12-10 16:08:40 UTC
README
A Twig extension to access Slim Flash messages in templates.
Install
Via Composer
composer require glazilla/slim-twig-flash
Requires:
- PHP 8 or newer
- Slim Framework Flash Messages 0.4.0 or newer
- Twig 3.4.3 or newer
Usage
- Add extension to your twig views
...
$view->addExtension(new Glazilla\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.