這可能是一個非常微不足道的/新手問題。我已經開始在我的一個控制器功能中使用Laravel Queue;但是,當我派遣工作時,我必須等待隊列完成才能讓我繼續使用該功能。我認爲隊列背後的全部概念是它可以讓你在後臺處理耗時的任務,因此你可以繼續使用其他功能。如何避免等待Laravel隊列並繼續使用功能
這是我的控制器看起來像:
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>'
]);
}