Download the PHP package volnix/flashy without Composer
On this page you can find all versions of the php package volnix/flashy. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download volnix/flashy
More information about volnix/flashy
Files in volnix/flashy
Package flashy
Short Description A wrapper around Symfony's HTTP foundation session flashbag to handle messages and form flash data
License MIT
Homepage https://github.com/volnix/flashy
Informations about the package flashy
Flashy
Simple wrapper around Symfony's Session flashbag.
There are two pieces to flashy: Messages.
Prefill Data
Often you will want to pre-fill form data from the last request when there are errors with user input. Flashy will accept input from any source, whether it was from POST/GET or a generated array. It is using Symfony's AutoExpireFlashBag container so data is cleared after every request whether it is read or not.
To set the form data is done by calling the set
method:
You would then call get
to retrieve data, optionally passing a default value to use if the key is not set.
To empty the form data storage, call the clear
function:
Messages
The Messages class will make handling flash messages a breeze. It is loosely tied to Bootstrap 3 for its alert markup, but this can easily be overridden. It is also using Symfony's AutoExpireFlashBag container.
The __call magic method is used to allow any type of messages for maximum portability.
To set a type of message, you may call any function, passing in a string or an array of messages, e.g.:
You may also set messages as an array of [type => messages], e.g.:
To retrieve them as an array, use the get
function (if not arg is passed, it will return all messages:
The real magic happen when you call the getFormatted
function:
Formatted messages are printed in the following markup:
To override the default Bootstrap alert syntax, pass an array of class overrides to the getFormatted
function:
will yield:
The Messages class also supports nesting of messages, e.g.:
will yield:
To empty the messages storage, call the clear
function:
All versions of flashy with dependencies
symfony/http-foundation Version 2.5.*@dev
satooshi/php-coveralls Version 0.7.0