laravel使用队列

第一步:不直接运行结果

.env 修改值

QUEUE_DRIVER=database

 

第二步:

创建job数据库

php artisan queue:table
php artisan migrate
如果报错  
[Illuminate\Database\QueryException]
SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes (SQL: alter table users add unique users_email_unique(email))

[PDOException]
SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes
修改  AppServiceProvider.php的boot 方法
 public function boot()
    {
        Schema::defaultStringLength(191);
    }
第三步,创建实现功能 每次 dispatch都会写入数据库 位置在app/jobs/下

php artisan make:command SendEmailXXXXXX

第四步:开启监听
php artisan queue:work --daemon
重启 队列
php artisan queue:restart

posted on 2018-05-27 17:33  yaolunhui  阅读(268)  评论(0编辑  收藏  举报

导航