ddaproduction/evocms-queue

0.0.3 2021-03-30 09:25 UTC

This package is auto-updated.

Last update: 2024-09-11 14:27:23 UTC


README

该包添加了使用队列的功能,类似于laravel,但除了dispatchable特性中的方法外。

dispatchIf  
dispatchUnless  
dispatchSync  
dispatchNow  
dispatchAfterResponse  
dispatchAfterResponse  
withChain  

安装

  1. php artisan package:install require ddaproduction/evocms-queue "*"
  2. php artisan vendor:publish --provider="EvolutionCMS\EvocmsQueue\EvocmsQueueServiceProvider"
  3. php artisan queue:table
  4. php artisan queue:failed-table
  5. php artisan migrate

配置

配置文件位于 core/custom/config/queue.php 文件夹中

使用方法

创建任务

  1. 在您方便的位置创建一个类,例如在包的 jobs 文件夹中。
  2. 继承自 EvolutionCMS\EvocmsQueue\AbstractJob。示例
<?php
namespace EvolutionCMS\Main\Jobs;

use EvolutionCMS\EvocmsQueue\AbstractJob;
use Illuminate\Queue\InteractsWithQueue;

class Foo extends AbstractJob
{
    use InteractsWithQueue;

    /**
     * Execute the job.
     */
    public function handle()
    {
        // do something
    }

}

将任务添加到队列

$q = evo()->make('queue');
$q->push(new Foo());

\Illuminate\Support\Facades\Queue::push(new \EvolutionCMS\Main\Jobs\Foo());