忽然之间的博客

Thoughts, stories and ideas.

Lumen自带队列配置


# 安装Lumen composer config -g repositories.packagist composer http://packagist.phpcomposer.com composer create-project --prefer-dist laravel/lumen lumen # redis 包 composer require "predis/predis ~1.0" composer require "illuminate/redis 5.3.*"

queue:failed-table 创建失败队列表的命令

按照Lumen官方文档,php artisan 并没有 queue:failed-table 这条命令

可是搜索源码发现有queue:failed-table的定义。 vendor/illuminate/queue/Console/FailedTableCommand.php 所以可以在Console中加上这个命令

vim vendor/illuminate/queue/ConsoleServiceProvider.php

<?php

use Illuminate\Queue\Console\FailedTableCommand;

class ConsoleServiceProvider extends ServiceProvider
{
    public function register()
    {
        $this->app->singleton('command.queue.failed-table', function () {
                return new FailedTableCommand($this->app['files'], $this->app['composer']);  # 定义
            });

            $this->commands(
                'command.queue.failed', 'command.queue.retry',
                'command.queue.forget', 'command.queue.flush',
                'command.queue.failed-table'  # 加入此命令
            );

    }

    public function provides()
    {
        return [
            'command.queue.failed', 'command.queue.retry',
            'command.queue.forget', 'command.queue.flush',
            'command.queue.failed-table',  # 添加进来
        ];
    }
}


再次执行 php artisan

php artisan

Available commands:
  help                Displays help for a command
  list                Lists commands
  migrate             Run the database migrations
  resque-worker       Run the Resque Worker
 cache
  cache:clear         Flush the application cache
 db
  db:seed             Seed the database with records
 make
  make:migration      Create a new migration file
 migrate
  migrate:install     Create the migration repository
  migrate:refresh     Reset and re-run all migrations
  migrate:reset       Rollback all database migrations
  migrate:rollback    Rollback the last database migration
  migrate:status      Show the status of each migration
 queue
  queue:failed        List all of the failed queue jobs
  queue:failed-table  Create a migration for the failed queue jobs database table               # 可以用这个来创建表了
  queue:flush         Flush all of the failed queue jobs
  queue:forget        Delete a failed queue job
  queue:listen        Listen to a given queue
  queue:restart       Restart queue worker daemons after their current job
  queue:retry         Retry a failed queue job
  queue:work          Start processing jobs on the queue as a daemon
 schedule
  schedule:run        Run the scheduled commands