根据Laravel 4 Documentation on queued Events ,我尝试以这种方式注册事件刷新器:
Event::flusher('foo.bar', function($data)
{
Mail::send(array('emails.notification', 'emails.notification_text'), array('content' => $data), function($message)
{
$message
->to('email@example.com', 'My Name')
->bcc('test@example.com')
->subject('Message from Listener');
});
});
但是我在加载脚本时收到以下错误:
Call to undefined method Illuminate\Events\Dispatcher::flusher()
我在L4的源码中也找不到这个方法。但是当我将它从 Event::flusher()
更改为 Event::listen()
时,一切都按预期工作。
所以我的猜测是,文档不是最新的并且 Event::flusher()
方法已被删除,因为 Event::listen()
做同样的工作。或者这两种方法之间有什么区别,我的代码有错误吗?
最佳答案
您可能需要使用以下方法更新您的库:
$ composer update
如果这不起作用,请告诉我们您的 composer.json
文件是什么样的 - 如果框架,您可能正在使用测试版。它在第一个稳定版本发布之前经常更新。
关于laravel - Laravel 4 中的排队事件:找不到 Event::flusher() 方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16818961/