mckay/flash

Handy flash messages.

v1.0.5 2016-02-17 04:37 UTC

This package is not auto-updated.

Last update: 2024-04-23 00:39:29 UTC


README

Tiny flash message library optimised for Bootstrap.

Install

Add it to your composer.json:

"mckay/flash": "^1.0.5",

then run $ composer update.

Usage

use \McKay\Flash;

Flash::info('Welcome home!');

if ($user->isNearACliff()) {
	Flash::warning('Careful, there');
}

$user->takeARandomStep();
Flash::debug('Uh oh?');

if ($user->heartbeat > 0) {
	Flash::success('Ok');
} else {
	Flash::error('Call an ambulance');
}

In your view

<? foreach(Flash::all() as $flash) { ?>
	<div class="alert alert-<?= $flash['type'] == 'error' ? 'danger' : $flash['type'] ?>">
		<button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>
		<?= $flash['message'] ?>
	</div>
<? } Flash::clear(); ?>

License

Copyright © McKay Software MIT License http://mckay.mit-license.org