Skip to content

martynbiz/php-flash-message

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Flash

Flash messenger that will keep messages until they are "flushed" - current or persistant states.

Installation

Composer

"require-dev": {
    "martynbiz/php-flash-message": "dev-master"
}

Usage

Add message

$flash = new \MartynBiz\FlashMessage\Flash;
$flash->addMessage('success', 'You have successfully registered');

Check if message exists by key

$flash->has('success'); // true
$flash->has('errors'); // false

Flush messages

This method can be called during the same HTTP request or future request. This means it is useful when redirecting but also forwarding to, for example, another controller action. The contents of the container will be emptied when this method is called once.

$messages = $flash->flushMessages();

Using custom storage

It is possible to use your own storage object, as long as it implements ArrayAccess interface. Below Zend\Storage\Container has been used:

$container = new Zend\Session\Container('mycontainer');
$flash = new Flash($container);

TODO

  • create a simple session storage as default

About

Flash messenger that will keep messages until they are \"flushed\" - current or persistant states.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages