【发布时间】:2016-08-17 21:06:41
【问题描述】:
这可能是一个非常琐碎/新手的问题。我已经开始在我的一个控制器功能中使用 Laravel Queue;但是,当我分派作业时,我必须等待队列完成才能让我继续使用该功能。我认为队列背后的整个概念是它允许您在后台处理时间密集型任务,以便您可以继续使用其余功能。
这是我的控制器的样子:
public function postCreate(Request $request)
{
// Validate Request
$this->validate($request, $this->rules());
// I have to wait for this to finish before it lets me continue
// I want this to be processed in the background instead
$this->dispatchFrom('App\Jobs\GenerateReport', $request);
return json_encode([
'html' => '<p>some html</p>'
]);
}
【问题讨论】: