PHP code example of lisio / yii2-mongodb-q

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

    

lisio / yii2-mongodb-q example snippets


return [
    // ...
    'bootstrap' => [
        // ...,
        'q',
    ],
    'components' => [
        // ...
        'queue' => [
            'class' => '\yii\q\components\QueueServer',
        ],
    ],
    'modules' => [
        // ...
        'q' => [
            'class' => 'yii\q\Module',
        ],
    ],
];

return [
    // ...
    'controllerMap' => [
        // ...
        'q' => 'yii\q\commands\QueueController',
    ],
    'components' => [
        // ...
        'queue' => [
            'class' => '\yii\q\components\QueueServer',
        ],
    ],
];

./yii q/create-indexes

Yii::$app->queue->queueCreate('test');

Yii::$app->queue->queuePurge('test');

Yii::$app->queue->queueRemove('test');

$data = [
    'someParam' => 'someValue',
];

$options = [
    'keepResult' => true,
    'keepResultDuration' => 86400,
];

$job = Yii::$app->queue->jobCreate('test', SomeWorker::className(), $data, $options);

Yii::$app->queue->jobPause($job->_id);

Yii::$app->queue->jobResume($job->_id);

Yii::$app->queue->jobRemove($job->_id);

Yii::$app->queue->jobRetry($job->_id);

Yii::$app->queue->jobStatus($job->_id);