2017 © Pedro Peláez
 

library phpflash

A simple library for flash messages.

image

joefallon/phpflash

A simple library for flash messages.

  • Sunday, September 18, 2016
  • by jfallon
  • Repository
  • 2 Watchers
  • 1 Stars
  • 51 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 10 Versions
  • 0 % Grown

The README.md

phpflash

By Joe Fallon, (*1)

The flash is a special part of the session which is cleared with each request. This means that values stored there will only be available in the next request. This is useful for passing error/success/warning/info messages to the user., (*2)

This library has the following features:, (*3)

  • Fully unit tested.
  • Allows flash message to be stored in either the session or in a temporary variable.
  • They following types of flash messages can be stored: info, warning, success, and error.

Installation

The easiest way to install PHP Flash is with Composer. Create the following composer.json file and run the php composer.phar install command to install it., (*4)

{
    "require": {
        "joefallon/phpflash": "*"
    }
}

Usage

Types of Messages

info    - Some event occurred that the user should be aware of.
warning - Something not good happened, but it isn't an error.
success - Whatever was attempted did, in fact, succeed.
error   - Some sort of program error occurred.

Working with Messages in the Session

To load and clear the messages that are in the session call the following:, (*5)

loadMessagesFromSession()

Calling #loadMessagesFromSession is required because once PHP begins sending the page data back to the client, the session can no longer be accessed., (*6)

Info Messages

storeInfoMessage($message, $storeInSession = true)
retrieveInfoMessages()

Success Messages

storeSuccessMessage($message, $storeInSession = true)
retrieveSuccessMessages()

Warning Messages

storeWarningMessage($message, $storeInSession = true)
retrieveWarningMessages()

Error Messages

storeErrorMessage($message, $storeInSession = true)
retrieveErrorMessages()

Example Usage on Two Separate Page Requests

$flash1 = new FlashMessages();
$flash1->storeInfoMessage('my info message', true);

later on the next request..., (*7)

$flash2 = new FlashMessages();
$flash2->loadMessagesFromSession();
$infoMessages = $flash2->retrieveInfoMessages();

Example Usage on the Same Page Request

$flash = new FlashMessages();
$flash->storeInfoMessage('my info message', false);

later on in the same request..., (*8)

$infoMessages = $flash->retrieveInfoMessages();

The Versions

18/09 2016

dev-master

9999999-dev https://github.com/joefallon/phpflash

A simple library for flash messages.

  Sources   Download

MIT

The Requires

 

The Development Requires

php flash messages

18/09 2016

dev-develop

dev-develop https://github.com/joefallon/phpflash

A simple library for flash messages.

  Sources   Download

MIT

The Requires

 

The Development Requires

php flash messages

18/09 2016

v3.0.1

3.0.1.0 https://github.com/joefallon/phpflash

A simple library for flash messages.

  Sources   Download

MIT

The Requires

 

The Development Requires

php flash messages

18/09 2016

v3.0.0

3.0.0.0 https://github.com/joefallon/phpflash

A simple library for flash messages.

  Sources   Download

MIT

The Requires

 

The Development Requires

php flash messages

27/12 2015

v2.0.0

2.0.0.0 https://github.com/joefallon/phpflash

A simple library for flash messages.

  Sources   Download

MIT

The Requires

 

The Development Requires

php flash messages

08/04 2015

v1.0.4

1.0.4.0 https://github.com/joefallon/phpflash

A simple library for flash messages.

  Sources   Download

MIT

The Requires

 

The Development Requires

php flash messages

08/04 2015

v1.0.3

1.0.3.0 https://github.com/joefallon/phpflash

A simple library for flash messages.

  Sources   Download

MIT

The Requires

 

The Development Requires

php flash messages

06/02 2015

v1.0.2

1.0.2.0 https://github.com/joefallon/phpflash

A simple library for flash messages.

  Sources   Download

MIT

The Requires

 

The Development Requires

php flash messages

06/02 2015

v1.0.1

1.0.1.0 https://github.com/joefallon/phpflash

A simple library for flash messages.

  Sources   Download

MIT

The Requires

 

The Development Requires

php flash messages

05/02 2015

v1.0.0

1.0.0.0 https://github.com/joefallon/phpflash

A simple library for flash messages.

  Sources   Download

MIT

The Requires

 

The Development Requires

php flash messages