PHP code example of dudashuang / php-queue

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

    

dudashuang / php-queue example snippets

shell
    composer 

    
    nector  = new Lily\Connectors\RedisConnector([
        'scheme'             => 'tcp',
        'host'               => '127.0.0.1',
        'port'               => 6379,
        'read_write_timeout' => 0,
    ]);
    $driver = new Lily\Drivers\Redis($connector);
    

    
    nector  = new Lily\Connectors\KafkaConnector([
        'brokers' => [
            ['host' => 'localhost', 'port' => 9092],
        ],
    ]);
    $driver = new Lily\Drivers\Kafka($connector);
    

    
    nector  = new Lily\Connectors\RabbitMQConnector([
        'host'     => 'localhost',
        'port'     => 5672,
        'username' => 'guest',
        'password' => 'guest',
    ]);
    $driver = new Lily\Drivers\RabbitMQ($connector);
    

    
    $application = new Lily\Application($driver, [
        'deafult_queue' => 'default-queue',
        'failed_queue'  => 'failed-queue',
    ]);
    

    for ($i=0; $i<10; $i++) {
        $application->dispatch(new TestJob('hello', new LilyTest\TestModel(1, 2)));
    }