PHP code example of fastd / queue

1. Go to this page and download the library: Download fastd/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/ */

    

fastd / queue example snippets


/**
 * Bootstrap service.
 */
'services' => [
    \FastD\ServiceProvider\RouteServiceProvider::class,
    \FastD\ServiceProvider\LoggerServiceProvider::class,
    \FastD\ServiceProvider\DatabaseServiceProvider::class,
    \FastD\ServiceProvider\CacheServiceProvider::class,
    \LinghitExts\AdminAuth\Provider\AdminAuthProvider::class,
    
    //加载消息队列服务
    \FastD\Queue\QueueServiceProvider::class,
],


//将ExampleJob加入到消息队列中
queue()->push(new FastD\Queue\Job\ExampleJob(false, false));


return [
    'host' => 'http://'.get_local_ip().':9527',
    'class' => \Server\TaskServer::class,
    'options' => [
        'user' => 'nobody',
        'group' => 'nogroup',
        'pid_file' => __DIR__ . '/../runtime/pid/' . app()->getName() . '.pid',
        'log_file' => __DIR__ . '/../runtime/logs/' . app()->getName() . '.pid',
        'log_level' => 5,
        'worker_num' => 10,
        'task_worker_num' => 20,
    ],
    'processes' => [
        //添加StartQueueProcess进程
        \FastD\Queue\Process\StartQueueProcess::class,
    ],
    'listeners' => [
        [
            'class' => \FastD\Servitization\Server\TCPServer::class,
            'host' => 'tcp://'.get_local_ip().':9528',
        ]
    ],
];