1. Go to this page and download the library: Download spanky/flasher 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/ */
spanky / flasher example snippets
use Spanky\Flasher\Factory as Flasher;
$flasher = Flasher::make();
session_start();
$flasher->addMessage('Welcome to the website!');
$flasher->addMessage('Congratulations, you are now signed up!', 'success');
$flasher->addMessage('Oh no, something went wrong!', 'error');
$flasher->addSuccess('Congratulations, you are now signed up!');
// identical to $flasher->addMessage('Congratulations, you are now signed up!', 'success');
if ($flasher->hasMessages())
{
echo '<ul>';
foreach($flasher->getMessages() as $message)
{
echo '<li class="'.$message->getType().'">', $message, '</li>';
}
echo '</ul>';
}
if ($flasher->hasMessages('success'))
{
echo '<ul>';
foreach($flasher->getMessages('success') as $message)
{
echo '<li class="'.$message->getType().'">', $message, '</li>';
}
echo '</ul>';
}
if ($flasher->hasMessages('error'))
{
echo '<div class="error"><strong>', $flasher->getMessages('error')->first(), '</strong></div>';
}