PHP code example of argayash / yii2-queue

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

    

argayash / yii2-queue example snippets


'components' => [
    'queue' => [
        'class' => \yii\queue\components\QueueComponent::className(),
        'queueName' => 'default-queue',
        'timeout' => 50, // optional
        'workers' => [
            'test' => [
                'class' => \yii\queue\components\WorkerComponent::className(),
                'action' => [
                    'class' => \console\controllers\TestController::className(),
                ]
            ],
            ...
        ],
        'channels' => [
            'default' => [
                'class' => \yii\queue\components\ChannelComponent::className(),
                    'driver' => [
                        'class' => \yii\queue\drivers\MysqlConnection::className(),
                        'connection' => 'db'
                    ]
                ]
            ],
            ...
        ]
    ]
]

./yii migrate/up --migrationPath=@vendor/argayash/yii2-queue/migrations

Yii::$app->queue->getChannel('default')->push(
    new MessageModel([
        'worker' => 'test',
        'method' => 'actionSayHello',
        'arguments' => [
            'say' => 'hello!'
        ]
    ])
);

\Yii::$app->queue->startDaemon();