Download the PHP package tochka-developers/queue-promises without Composer

On this page you can find all versions of the php package tochka-developers/queue-promises. 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 queue-promises

Queue Promises

Packagist Packagist build Psalm coverage Psalm level Coverage Status

The module allows chaining of Laravel jobs. The promise will be executed after all chained jobs are finished (either completed successfully or failed). The promise has access to job results.

Installation

Usage

Creating a Promise

All promises are derived from Tochka\Queue\Promises\Jobs\Promise. You can create a template promise with artisan:

Class details

The promise class is rather straightforward, as only two methods are needed: success and errors. The success is called by the provider if all chained jobs have completed successfully. The errors is called if any of the jobs failed.

Any of the methods shown above may not be implemented. If a methods is missing it is assumed to do nothing and return true.

Chain Initialization

In order for jobs to attach to a promise they must implement the Tochka\Queue\Promises\Contracts\MayPromised interface. The most common use cases are collected in the Tochka\Queue\Promises\Jobs\Promised trait. You may simply attach these to your class like this:

The chain is constructed by adding any number of jobs to the promise:

After that the promise can be run in one of two modes:

The termination conditions can be finely configured via method call:

For convenience, runSync and runAsync may also take the same parameters.

Waiting For Events

Sometimes it is necessary to execute a promise not just after a number of jobs completed, but also when an event is dispatched. Waiting for the events is done with a Tochka\Queue\Promises\Jobs\WaitEvent job:

The constructor of a WaitEvent takes a class of the event to wait for and an unique identifier (of unspecified type). If the identifier is not provided, the WaitEvent will wait for any event of the expected class. If the identifier is given to the constructor, the WaitEvent will complete only when the event with this identifier is dispatched. In order for this to work, the event must implement the Tochka\Queue\Promises\Contracts\PromisedEvent interface:

getUniqueId must return either an identifier or null if no identifier exists.

Note that WaitEvent will never complete if it waits for a class that does not implement the interface.

Promise Timeout

It may be useful at times to execute the promise after a timeout event if some of chained jobs haven't yet finished. This is achieved with a special delayed checker job.

You have to configure the timeout subsystem:

After that the promises may be set to expire. Two ways of setting a timeout are possible:

If the promise times out, the timeout method is called (if defined).

Processing The Results

The getResults method returns the results of all chained jobs:

Job results are returned as classes implementing Tochka\Queue\Promises\Contracts\MayPromised.

Dependency Injection

An alternative way to get the job results is dependency injection versions of generic methods before, success, errors, timeout, and after:

The DI works like follows:

Note that if the promise is run asynchronously, the order of job execution cannot be guaranteed. This may have undesired consequences:

Tochka\Queue\Promises\Contracts\MayPromised interface declares the following methods:


All versions of queue-promises with dependencies

PHP Build Version
Package Version
Requires php Version 8.1.*|8.2.*|8.3.*
ext-json Version *
ext-pcntl Version *
bensampo/laravel-enum Version ^2.1|^3.0|^4.0|^5.0|^6.0
laravel/framework Version ^v8.37|^9.0|^10.0|^11.0
nesbot/carbon Version ^2.0|^3.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 tochka-developers/queue-promises contains the following files

Loading the files please wait ....