germania-kg/flashmessages

Pimple Service Provider for Slim Framework flash messages

1.1.3 2022-03-30 10:14 UTC

This package is auto-updated.

Last update: 2024-11-29 05:09:42 UTC


README

Pimple Service Provider for Slim Framework flash messages

Packagist PHP version Build Status Scrutinizer Code Quality Code Coverage Build Status

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