dev-master
9999999-dev http://dbwebb.seSmall session based flash class, written mainly for Anax-MVC.
MIT
The Requires
- php >=5.4
mvc anax flash kalkih flashy
Wallogit.com
2017 © Pedro PelĂĄez
Small session based flash class, written mainly for Anax-MVC.
A small PHP flash class to store and get information and messages., (*2)
Flashy comes with a simple and minimalistic pre-defined stylesheet. Flashy supports four different message types (info, success, warning and error). Flashy does also support Font Awesome. (see instructions below for code examples)., (*3)
, (*4)
Add the following to the top of your frotcontroller., (*5)
// Get environment & autoloader, the $di & $app-object.
require __DIR__.'/config_with_app.php';
// Services
$di->setShared('flash', function() {
$flash = new \kalkih\Flash\Flash();
return $flash;
});
// Other services, modules, controllers here
// Starts the session (required by the Flashy class)
$app->session;
If you want to use the bundled flashy stylesheet add following code to the frontcontroller (Note: you have to copy the stylesheet to your css folder for this to work)., (*6)
// Extra stylesheets
$app->theme->addStylesheet('css/flashy.css');
You can now use the Flashy class., (*7)
// From a route in the frontcontroller:
$app->flash->add('info', 'This is a info message');
$app->flash->add('success', 'This is a success message');
$app->flash->add('warning', 'This is a warning message');
$app->flash->add('error', 'This is a error message');
// From a controller:
$this->flash->add('info', 'This is a info message');
$this->flash->add('success', 'This is a success message');
$this->flash->add('warning', 'This is a warning message');
$this->flash->add('error', 'This is a error message');
To get message/messages and print it/them out, just add following code to a view, (*8)
$app->flash->get(); // or if in a view / controller $this->flash->get();
The output should look like this, (*9)
<div class="flashy_info">
This is a info message
</div>
<div class="flashy_success">
This is a success message
</div>
<div class="flashy_warning">
This is a warning message
</div>
<div class="flashy_error">
This is a error message
</div>
If you have support for Font Awesome and want to show related icons with each message use the code below., (*10)
$app->flash->get('icons');
// or if in a view / controller
$this->flash->get('icons');
The output with icons should look like this:, (*11)
<div class="flashy_info">
<i class="fa fa-info-circle"></i>
This is a info message
</div>
<div class="flashy_success">
<i class="fa fa-check"></i>
This is a success message
</div>
<div class="flashy_warning">
<i class="fa fa-warning"></i>
This is a warning message
</div>
<div class="flashy_error">
<i class="fa fa-times-circle"></i>
This is a error message
</div>
Small session based flash class, written mainly for Anax-MVC.
MIT
mvc anax flash kalkih flashy