2017 © Pedro PelĂĄez
 

library flashy

Small session based flash class, written mainly for Anax-MVC.

image

kalkih/flashy

Small session based flash class, written mainly for Anax-MVC.

  • Thursday, May 15, 2014
  • by kalkih
  • Repository
  • 1 Watchers
  • 2 Stars
  • 1 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

Flashy

Build Status Scrutinizer Code Quality Code Coverage, (*1)

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)

Preview

alt tag, (*4)

Functions

  • add('Message type', 'Your message') // Add a new message
  • get('Extra parameter') // Get messages as HTML (optionally: parameter)
  • clear() // Clear all messages, also called from get()

Valid message types:

  • 'info'
  • 'success'
  • 'warning'
  • 'error'

Valid get parameters:

  • 'icons' // Adds Font Awesome icons to the output

Instructions for Anax-MVC

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>

The Versions

15/05 2014

dev-master

9999999-dev http://dbwebb.se

Small session based flash class, written mainly for Anax-MVC.

  Sources   Download

MIT

The Requires

  • php >=5.4

 

mvc anax flash kalkih flashy