germania-kg / flashmessages
Pimple Service Provider for Slim Framework flash messages
1.1.3
2022-03-30 10:14 UTC
Requires
- pimple/pimple: ^3.0
- slim/flash: ^0.4.0
Requires (Dev)
- php-coveralls/php-coveralls: ^2.0
- phpunit/phpunit: ^5.7|^6.0|^7.0
README
Pimple Service Provider for Slim Framework flash messages
Installation with Composer
$ composer require germania-kg/flashmessages
Alternatively, add this package directly to your composer.json:
"require": { "germania-kg/flashmessages": "^1.0" }
Usage
<?php use Pimple\Container; use Slim\Flash\Messages; use Germania\FlashMessages\FlashMessagesServiceProvider; // 'Slim Flash Messages' object is optional $flash_services = new FlashMessagesServiceProvider; $flash_services = new FlashMessagesServiceProvider( new Messages ); // Setup Pimple container $container = new Container; $container->register( $flash_services ); // Shortest Setup: $container->register( new FlashMessagesServiceProvider );
Setting Flash Messages
$flash_setter = $container['FlashMessages.Setter']; $flash_setter( $keyword, $message );
Getting Flash Messages
$flash_getter = $container['FlashMessages.Getter']; // Get one single message. $flash_getter( $keyword ); // $keyword is optional; leave empty to get ALL messages $flash_getter();
Development
$ git clone https://github.com/GermaniaKG/FlashMessages.git
$ cd FlashMessages
$ composer install
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:
$ composer test # or $ vendor/bin/phpunit