This package provides a robust queue system for Craft CMS.
To install, use composer:
composer require flipboxdigital/queue
In the Craft Control Panel, go to Settings → Plugins and click the "Install" button for Queue.
By default, multiple queues are supported. In order to add a new queue, register it via an event in your Plugin::init()
:
yii\base\Event::on(
flipbox\queue\queues\MultipleByEvent::class,
flipbox\queue\queues\MultipleByEvent::EVENT_REGISTER_QUEUES,
function(flipbox\queue\events\RegisterQueues $event) {
$event->queues[] = [
'class' => flipbox\queue\queues\Sqs::class,
'url' => 'https://sqs.us-west-2.amazonaws.com/1234567890/xxxxxx',
'config' => [
'region' => 'us-west-2',
'version' => 'latest'
]
];
}
);
To post a new job (extend flipbox\queue\jobs\AbstractJob
)
$job = new Your\Test\Job();
Queue::getInstance()->getQueue()->post($job);
To run a job:
$job = Queue::getInstance()->getQueue()->fetch();
if ($job) {
Queue::getInstance()->getQueue()->run($job);
}
$ ./vendor/bin/phpunit
Please see CONTRIBUTING for details.
The MIT License (MIT). Please see License File for more information.