1. Go to this page and download the library: Download felixdorn/flash library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
felixdorn / flash example snippets
use Felix\Flash\Drivers\SessionDriver;
use Felix\Flash\Flash;
use Felix\Flash\Templates\SpectreTemplate;
$driver = new SessionDriver([
// session_start options
// see https://www.php.net/manual/fr/function.session-start.php
]);
// A random template
$template = new SpectreTemplate();
$flash = new Flash($driver, $template);
$flash->success('message');
$flash->warning('message1');
$flash->render(); // implicitly it's $flash->render('all')
// render 'message' and 'message1' using the defined template
$flash->render('success');
// render 'message' but not 'message1'
$flash->message('really-important', 'In movie gone in 60 seconds, things are gone in 60 seconds');
$flash->render(); // will also render `really-important` as a normal type.
$flash->render('really-important'); // will render `really-important` flashes using the default template
$flash->success('Cool!');
$flash->clear('success'); // delete every success flash using the Driver
$flash->render(); // Won't render anything
$flash->success('Cool!');
$flash->error('Uhhhh.');
$flash->clear(); // Clear every flashes
$flash->render(); // Won't render anything
$flash->error('Bad thing.');
$flash->disable();
// NOTE: Here, when disabling, you can still clear or render
$flash->success('Good thing');
$flash->enable();
$flash->render('all'); // 'all' is optional, it's the default value
// Here, only 'Bad thing.' will be rendered.
use Felix\Flash\Templates\TemplateInterface;
class MyTemplate implements TemplateInterface {
public function toHtml(string $type,string $message){
return sprintf('<div class="alert %s">%s</div>', $type, $message);
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.