Phalcon PhP - 闪现消息未显示

Phalcon PhP - flash messages not showing

我在使用 Phalcon PhP 显示 flash 消息时遇到问题。这是我注册服务的方式:

use Phalcon\Flash\Direct as Flash;
$di->set('flash', function () {
    return new Flash(array(
        'error'   => 'alert alert-danger',
        'success' => 'alert alert-success',
        'notice'  => 'alert alert-info',
        'warning' => 'alert alert-warning'
    ));
});

在我的控制器中,我添加了这样的闪现消息

$this->flash->success('The carrier was successfully activated');

在我看来,我尝试这样显示(伏特):

{{ flash.output() }}

我的布局有 {{ content() }} 标签,我已尝试应用 this post 中讨论的内容,但无论如何它都不起作用。

你能看出我在这里遗漏了什么吗?感谢您的帮助!

您使用的 Flash 会话有误。而不是

use Phalcon\Flash\Direct as Flash;

使用

use Phalcon\Flash\Session as Flash;

documentation 说:

  • Flash\Direct 将直接输出传递给 闪光。
  • Flash\Session 会将消息暂时存储在 session,然后可以在下一个请求中打印消息