elms / eflashmessage
用于为Anax创建Flash消息的PHP类
v1.0
2016-02-23 13:45 UTC
Requires
- php: >=5.4
This package is not auto-updated.
Last update: 2024-09-14 19:03:59 UTC
README
在会话中保存消息并在调用时显示。用于Anax-MVC
安装
使用Packagist安装或从Github源克隆代码
"elms/eflashmessage": "dev-master"
在您的Anax MVC框架中,添加以下代码以在DI中调用FlashController:
$di->set('FlashController', function() use ($di) {
$flashController = new \Anax\FlashMessages\FlashController();
$flashController->setDI($di);
return $flashController;
});
或者
- 将文件webroot/testflash.php放入Anax的webroot中
- 并将文件css/EFlashMessage.css放入webroot/css
- 启动并测试不同的消息!
在文件webroot/testflash.php中,您可以找到四个不同的调用,用于info、alert、success和error消息;
为了在会话中保存消息 - 错误消息
$app->msg->error('Error flash meddelande!!');
成功消息
$app->msg->success('Success flash meddelande!!');
信息消息
$app->msg->info('Info flash meddelande!!');
alert消息
$app->msg->alert('Alert flash meddelande!!');
要打印消息,请使用:
$app->theme->setVariable('title', "Flash messages")->setVariable('main', $app->msg->outputMsgs());
要清除会话中的消息,请使用;
$app->msg->clearMsg();