* 注册事件
*/
protected function listenForEvents()
{
$this->app->event->listen(JobProcessing::class, function ($event) {
$this->writeOutput($event->job, 'starting');
});
$this->app->event->listen(JobProcessed::class, function ($event) {
$this->writeOutput($event->job, 'success');
});
$this->app->event->listen(JobFailed::class, function ($event) {
$this->writeOutput($event->job, 'failed');
$this->logFailedJob($event);
});
}
回调的event是个闭包,导致$event->job提示空引用,不知道解决了没用?还是我用法不正确?
最佳答案