<?php namespace App\Jobs; use App\Models\UsersModel; use Illuminate\Bus\Queueable; use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Foundation\Bus\Dispatchable; use Illuminate\Queue\InteractsWithQueue; use Illuminate\Queue\SerializesModels; use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\Log; class SendEmail implements ShouldQueue { use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
public $user; /** * Create a new job instance. * * @return void */ public function __construct($user)
$this->user=$user; } /** * Execute the job. * * @return void */
public function handle() { Log::info('send remind eamil to'. $this->user); } } ## 第二种方式用redis 1. 步骤和第一种一样只是选择的时候选择 redis 2.需要安装redis扩展 composer require predis/predis 这只是建立链接一样 然后服务端也要安装这里用phpstudy在上面安装redis包 这样项目才能使用redis 3.如果报错 production.ERROR: Please make sure the PHP Redis extension is installed and enabled 1.选查看 PHP的redis扩展有没有打开 2.在config/database.php文件下的redis配置,将client配置修改成如下 'client' => env('REDIS_CLIENT', 'predis'),