Flasher is a PHP Class for handling flash messages in Anax-MVC.
- PHP 5.4 or higher
- FontAwesome (optional)
- Move/copy "config/flasher_conf.php" to app/config.
- Move/copy files in "views"-folder to app/views/flasher.
Place the following code in src/DI/CDIFactoryDefault.php:
$this->setShared('flasher', function() {
$flasher = new \Epj\Flasher();
$flasher->setOptions(require ANAX_APP_PATH . 'config/flasher_conf.php');
$flasher->setDI($this);
return $flasher;
});
Make sure session is started, otherwise start it! You can start it by placing the following code in webroot/config_with_app.php:
// You can start session in webroot/config_with_app.php
$app->session();
Add the following code to the theme file: Make sure it is placed at the top of the file.
$this->di->flasher->get();
Add the following code to the theme file where you want the flash message to be rendered.
if(isset($flash_message)) echo $flash_message;
$this->views->render('flash_message');
Set up the flash message types you want to use in the config file. You can choose any type you want as long as it follows the same pattern as the example configuration file.
Flash a message of the type you specified in the config file. Example:
$app->flasher->success("This is a flash message of the type 'success'");
This software is free software and carries a MIT license.