사용자가 응용 프로그램에 등록 할 때 전자 메일을 보낼 작업이 있습니다.대기열 작업을 만드는 방법 : work
SendWelcomeEmail.php
<?php
namespace App\Jobs;
use App\Jobs\Job;
use App\User;
use Illuminate\Contracts\Mail\Mailer;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
class SendWelcomeEmail extends Job implements ShouldQueue
{
use InteractsWithQueue, SerializesModels;
protected $user;
/**
* Create a new job instance.
*
* @return void
*/
public function __construct(User $user)
{
$this->user = $user;
}
/**
* Execute the job.
*
* @return void
*/
public function handle(Mailer $mailer)
{
$user = &$this->user;
$message = sprintf('Hello %s', $user->name);
$mailer->raw($message, function ($m) use ($user){
$m->from('[email protected]', 'Lucas Lopes');
$m->to($user->email, $user->name);
});
}
}
나는 PHP 장인 큐를 실행하는 작업을 생성하고 싶습니다 : 작업 명령 큐에있는 전자 메일을 보낼 수있는 모든 분.
가있는 명령을 설정할 필요가 없습니다이 크론은 Laravel 명령 스케줄러에게 매 순간을 호출 할이
* * * * * php /path-to-your-project/artisan schedule:run >> /dev/null 2>&1
처럼 크론을 추가 할 수 있습니다 'app/Console/Kernel.php' 얼마나 자주 실행됩니까? –