Download the PHP package urbanindo/yii2-queue without Composer

On this page you can find all versions of the php package urbanindo/yii2-queue. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package yii2-queue

Queue Component for Yii2

This provides queue component for Yii2.

Latest Stable Version Total Downloads Latest Unstable Version Build Status codecov

Requirements

You need PCNT extension enabled to run listener

Installation

The preferred way to install this extension is through composer.

Either run

or add

to the require section of your composer.json file.

To use Redis queue or RabbitMQ, you have to add yiisoft/yii2-redis:* or videlalvaro/php-amqplib: 2.5.* respectively.

Setting Up

After the installation, first step is to set the console controller.

For the task worker, set a new module, e.g. task and declare it in the config.

And then set the queue component. Don't forget to set the module name that runs the task in the component. For example, queue using AWS SQS

Or using Database queue

Usage

Creating A Worker

Creating a worker is just the same with creating console or web controller. In the task module create a controller that extends UrbanIndo\Yii2\Queue\Worker\Controller

e.g.

To prevent the job got deleted from the queue, for example when the job is not completed, return false in the action. The job will be run again the next chance.

e.g.

Running The Listener

To run the listener, run the console that set in the above config. If the controller mapped as queue then run.

Posting A Job

To post a job from source code, put something like this.

Job can also be posted from the console. The data in the second parameter is in JSON string.

Job can also be posted as anonymous function. Be careful using this.

Deferred Event

In this queue, there is a feature called Deferred Event. Basically using this feature, we can defer a process executed after a certain event using queue.

To use this, add behavior in a component and implement the defined event handler.

NOTE Due to reducing the message size, the $event object that usually passed when triggered the event will not be passed to the deferred event. Also, the object in which the method invoked is merely a clone object, so it won't have the behavior and the event attached in the original object.

As for ActiveRecord class, since the object can not be passed due to limitation of SuperClosure in serializing PDO (I personally think that's bad too), the behavior should use \UrbanIndo\Yii2\Queue\Behaviors\ActiveRecordDeferredEventBehavior instead. The difference is in the object in which the deferred event handler invoked.

Since we can not pass the original object, the invoking object will be re-fetched from the table using the primary key. And for the afterDelete event, since the respective row is not in the table anymore, the invoking object is a new object whose attributes are assigned from the attributes of the original object.

Web End Point

We can use web endpoint to use the queue by adding \UrbanIndo\Yii2\Queue\Web\Controller to the controller map.

For example

To post this use

To limit the access to the controller, we can use \yii\filters\AccessControl filter.

For example to filter by IP address, we can use something like this.

Testing

To run the tests, in the root directory execute below.

Road Map


All versions of yii2-queue with dependencies

PHP Build Version
Package Version
Requires php Version ^7.2
ext-pcntl Version *
yiisoft/yii2 Version >=2.0.15
aws/aws-sdk-php Version >=2.4
symfony/process Version >=2.4
jeremeamia/superclosure Version >=2.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package urbanindo/yii2-queue contains the following files

Loading the files please wait ....