PHP code example of nasustop / hapi-queue

1. Go to this page and download the library: Download nasustop/hapi-queue library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

nasustop / hapi-queue example snippets


$job = new DemoJob(['name' => 'hapi']);
(new Producer($job))->onQueue('test')->dispatcher();

php bin/hyperf.php vendor:publish nasustop/hapi-queue
shell
php bin/hyperf.php hapi:queue:work [queue]
shell
# 新建process文件DemoProcess.php
# queue配置文件中设置了几个队列,就建立几个process文件,$queue 为配置中的队列名称



namespace App\Demo;

use Nasustop\HapiQueue\Consumer;

class DemoConsumer extends Consumer
{
    protected string $queue = 'default';
}

# 将DemoProcess加入到process配置文件中
# cat config/autoload/processes.php


return [
    App\Process\Queue\QueueDefaultProcess::class,
];