PHP code example of volnix / flashy

1. Go to this page and download the library: Download volnix/flashy 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/ */

    

volnix / flashy example snippets


use Symfony\Component\HttpFoundation\Request;
use Volnix\Flashy\FormData;

$request = Request::createFromGlobals();
$form_data = new FormData;
$form_data->set($request->query->all());

use Volnix\Flashy\FormData;

$form_data = new FormData;
$form_data->set(['foo' => 'bar']);

echo $form_data->get('foo'); // bar
echo $form_data->get('bim', 'baz'); // baz

use Volnix\Flashy\FormData;

$form_data = new FormData;
$form_data->set(['foo' => 'bar']);

echo $form_data->set('foo'); // bar

$form_data->clear();
echo $form_data->get('foo', 'baz'); // baz

use Volnix\Flashy\Messages;

$messages = new Messages;
$messages->error('Oh no!');
$messages->info(['Message one', 'Message two']);

use Volnix\Flashy\Messages;

$messages = new Messages;
$messages->setAsArray(['error' => 'foo');

use Volnix\Flashy\Messages;

$messages = new Messages;
$messages->error('Oh no!');
$messages->info(['Message one', 'Message two']);

foreach ($messages->get('error') as $error_message) {
	echo $error_message;
}

$all_messages = $messages->get();

use Volnix\Flashy\Messages;

$messages = new Messages;
$messages->error('Oh no!');
$messages->info(['Message one', 'Message two']);

// print all the error messages:
echo $messages->getFormatted('error');

// print all the messages:
echo $messages->getFormatted();

use Volnix\Flashy\Messages;

$messages = new Messages;
$messages->error('Oh no!');

echo $messages->getFormatted('error', ['error' => 'bip']);

use Volnix\Flashy\Messages;

$messages = new Messages;
$messages->error(['foo', 'bar' => ['bip', 'bap']]);

echo $messages->getFormatted('error');

use Volnix\Flashy\Messages;

$messages = new Messages;
$messages->set(['foo' => 'bar']);

echo $messages->get('foo'); // bar

$messages->clear();
echo $messages->get('foo', 'baz'); // baz