dev-master
9999999-dev http://pbjuhr.sePhp class for generating and displaying messages to the user.
MIT
The Requires
- php >=5.4
by Peter Bjuhr
messages status flash
Wallogit.com
2017 © Pedro Peláez
Php class for generating and displaying messages to the user.
Php class for generating and displaying flash messages., (*2)
The easiest way is to install using composer. Add to your composer.json:, (*3)
"require": {
"pbjuhr/flashmessages": "dev-master"
},
Do not forget to run composer update!, (*4)
Don't wanna use Composer? Download .zip from this page!, (*5)
Session must be started before using FlashMessages.
To include FlashMessages in your ANAX-application, add the class in your front
controller:, (*6)
$di->setShared('FlashMessages', function() use ($di) {
$FlashMessages = new \PBjuhr\FlashMessages\FlashMessages($di);
return $FlashMessages;
});
Replace FlashMessages.php with FlashMessages_NoANAX.php and include it in your project., (*7)
require "FlashMessages.php" $myFlashMessagesObject = new FlashMessages();
Four different types of messages can be generated. Info, Success, Warnings or Errors! Add a message using one of the following functions:, (*8)
$content = "<strong>Heads up!</strong> This is a flash message."; $type = "info"; /* Must be: "info", "success", "warning" or "error" */ $myFlashMessagesObject->add($type, $content); $myFlashMessagesObject->addInfo($content); $myFlashMessagesObject->addSuccess($content); $myFlashMessagesObject->addWarning($content); $myFlashMessagesObject->addError($content);
Here's an example how to add a message in ANAX:, (*9)
$app->FlashMessages->addSuccess($content);
To display messages, simply call the function getHtml($class). $class is an optional parameter that sets a css-class to the div objects. Standard css-class is "alert" for bootstrap users!, (*10)
echo $myFlashMessagesObject->getHtml("myCssClass");
Each message gets printed in the following format:, (*11)
<div class="myCssClass myCssClass-type" role="alert">Content</div>
Where "type" is either "success", "info", "warning" or "danger". (Bootstrap standard) Note! The getHtml sets the messages session to NULL before returning., (*12)
MIT, (*13)
Php class for generating and displaying messages to the user.
MIT
messages status flash