Laravel队列未作为后台运行 [英] Laravel Queue doesnt run as background
本文介绍了Laravel队列未作为后台运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我创建了一个laravel队列作业来发送邮件
hi i created a laravel queue job to send mails
public function handle() {
foreach($this->emails as $value) {
$to = $value->email;
$subject = $this->data['subject'];
$this->data['t_firstname'] = $value->firstname;
$this->data['t_lastname'] = $value->lastname;
if (view()->exists('mail.requirement_to_tutor')) {
$view = view('mail.requirement_to_tutor',$this->data);
$html = $view->render();
}
file_put_contents('test.txt', 'test database');
$body = $html;
$headers = "From: " . $this->data['from'] . "\r\nReply-To: " . $this->data['from'] . "";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset: utf8\r\n";
mail($to, $subject, $body, $headers);
}
}
我也正在推送回购中的数据
and also i am pushing datas from repo
$obj = (new SendStudentRequirement($TutorsbyCity,$data));
$this->dispatch($obj);
但是它不能作为后台运行,功能正在等待队列完成,请帮帮我
but it doesnot run as background , the function is waiting untill the queue finish , help me out please
推荐答案
默认情况下使用 sync 驱动程序.您应该将此更改为config/queue.php
By default the sync driver is used. You should change this to another driver that is listed in config/queue.php
在.env
文件中查找以下行,并调整为其他驱动程序:
Look for the following line in your .env
file and adjust to a different driver:
QUEUE_DRIVER=sync
这篇关于Laravel队列未作为后台运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文