, (*1)
FlashMessage
This is a module for the Anax-MVC web framework. The module has been developed as a part of a course on Blekinge Tekniska Högskola., (*2)
Flash messages are used to display status messages, results of actions or notices. Use this component to generate these types of messages., (*3)
The class FlashMsg uses the session service in Anax-MVC to store the messages until the array is cleared., (*4)
Installation
- To install, use composer.
- Add this line into your composer.json file:
"require": {"helikopterspark/flashmsg": "dev-master"}
- Move or copy the css/flashmsg.css file to the webroot/css folder in your Anax-MVC installation. Modify it to your liking.
- In the router you also need to add the css-stylesheet flashmsg.css.
- You can move or copy the file flashmessages.php to your webroot to test in a web browser.
Access the controller in your frontcontroller:
$di->setShared('flashmessage', function() use ($di){
$flashMessages = new \helikopterspark\FlashMsg\FlashMsg();
$flashMessages->setDI($di);
return $flashMessages;
});
Add the route in your frontcontroller:
$app->router->add('', function() use ($app) {
$app->theme->addStylesheet('css/flashmsg.css');
$app->theme->setTitle("Flash messages");
$app->flashmessage->alert('Alert');
$app->flashmessage->error('Error');
$app->flashmessage->info('Info');
$app->flashmessage->notice('Notice');
$app->flashmessage->success('Success');
$app->flashmessage->warning('Warning');
$app->views->add('theme/index', ['content' => $app->flashmessage->outputMsgs()]);
$app->flashmessage->clearMessages();
});