erogami/cfmessage

Class for flash messages

dev-master 2015-01-17 17:05 UTC

This package is not auto-updated.

Last update: 2025-08-30 21:46:46 UTC


README

Build Status Scrutinizer Code Quality Code Coverage

Cfmessage

Flash messages, a class to show sucess, info, warning and error messages for the user.

By Alex Chau, alex_chau6@hotmail.com

Instructions

###1. Download

First of all install by using composer. Add this code to your composer.json:

"require": {
    "erogami/cfmessage": "dev-master"
},

###2. Include Cfmessage in your framework

Add this code to your front-controller.

$di->set('Cfmessage', function() use ($di) { 
    $message = new \erogami\Cfmessage\Cfmessage($di);  
    return $message; 
}); 

Now add these lines to get your message.

For info messages:

    $app->Cfmessage->addInfo('This is an information message'); 

For error messages:

    $app->Cfmessage->addError('This is an error message'); 

For warning messages:

    $app->Cfmessage->addWarning('This is a warning message'); 

For success messages:

    $app->Cfmessage->addSuccess('This is a success message'); 

The messages will be saved in the session, call these lines to print out the messages:

    $messages = $app->Cfmessage->printMessage();
    $app->views->addString($messages);

The class uses Font Awesome, but works without it too. So it's optional wheter you want to include the icons or not.