Skip to content

flipbox/queue

Repository files navigation

Queue system for Craft CMS

Latest Version Software License Build Status Coverage Status Quality Score Total Downloads

This package provides a robust queue system for Craft CMS.

Installation

To install, use composer:

composer require flipboxdigital/queue

In the Craft Control Panel, go to Settings → Plugins and click the "Install" button for Queue.

Usage

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);
}

Testing

$ ./vendor/bin/phpunit

Contributing

Please see CONTRIBUTING for details.

Credits

License

The MIT License (MIT). Please see License File for more information.