2017 © Pedro PelĂĄez
 

yii2-extension yii2-queues

A queuning service which is implemented by redis for Yii2 framework.

image

ancoka/yii2-queues

A queuning service which is implemented by redis for Yii2 framework.

  • Thursday, February 9, 2017
  • by ancoka
  • Repository
  • 1 Watchers
  • 2 Stars
  • 8 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

About

Yii2-queues is a redis implementation based Yii framework queue extension service. The code is slightly modified on the basis of Chris Boulton's php-resque, using the PSR4 standard, adding namespace support, and inheriting the Yii2 component., (*1)

Requirements

  • PHP 5.3+
  • Redis 2.2+
  • Composer

Install

The preferred way to do this is through the composer., (*2)

Directly use the composer command to install:, (*3)

php composer.phar require --prefer-dist soyaf518/yii2-queues "*"

Or add the following to your project's "composer.json" file:, (*4)

"soyaf518/yii2-queues": "*"

And running:, (*5)

composer install

Configuration

To use this extension, you have to configure the ResqueComponent class in your application configuration:, (*6)

return [
    //...
    'components' => [
        'resque' => [
            'class' => 'queues\ResqueComponent',
            'server' => '127.0.0.1',
            'port' => 6379,
            'database' => 0,
            'user' => '',
            'password' => '',
            'options' => [
                'timeout' => '',
                'persistent' => '',
            ],
        ],
    ]
];

Usage

Once the extension is installed, simply use it in your code by :, (*7)

  1. Queueing Jobs, (*8)

    Jobs are queued as follows:, (*9)

    <?php
    $data = array(
            'name' => 'yii-queues'
        );
    
    # Real-time execution
    Yii::$app->resque->put('default', $data);
    
    # Delayed execution
    Yii::$app->resque->putIn('default', $data, 10);
    
    # Timing execution
    Yii::$app->resque->putAt('default', $data, 1486620571);
    
    
  2. Defining Jobs, (*10)

    class DefaultWorker
    {
        public function setUp()
        {
            // ... Set up environment for this job
        }
    
        public function perform()
        {
            $data = Yii::$app->resque->getArgs($this->args);
    
            // @todo deal with this data
        }
    
        public function tearDown()
        {
            // ... Remove environment for this job
        }
    }
    
  3. Workers, (*11)

    To start a worker:, (*12)

    $ QUEUE=file_serve php bin/resque
    
    
  4. Running All Queues, (*13)

    All queues are supported in the same manner and processed in alphabetical order:, (*14)

    $ QUEUE='*' bin/resque
    
  5. Running Multiple Workers, (*15)

    Multiple workers can be launched simultaneously by supplying the COUNT environment variable:, (*16)

    $ COUNT=5 bin/resque
    

Thanks

The Versions

09/02 2017

dev-master

9999999-dev

A queuning service which is implemented by redis for Yii2 framework.

  Sources   Download

MIT

The Requires

 

by Avatar ancoka

extension yii2 queue resque

09/02 2017

1.0.0

1.0.0.0

A queuning service which is implemented by redis for Yii2 framework.

  Sources   Download

MIT

The Requires

 

by Avatar ancoka

extension yii2 queue resque