mckay/flash

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

This package is not auto-updated.

Last update: 2024-09-24 02:49:21 UTC


README

专为Bootstrap优化的小型闪存消息库。

安装

将其添加到composer.json文件中

"mckay/flash": "^1.0.5",

然后运行$ composer update

使用方法

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');
}

在您的视图中

<? 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(); ?>

许可证

版权 © McKay Software MIT许可证 http://mckay.mit-license.org