PHPackages                             tochka-developers/queue-promises - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Queues &amp; Workers](/categories/queues)
4. /
5. tochka-developers/queue-promises

ActivePackage[Queues &amp; Workers](/categories/queues)

tochka-developers/queue-promises
================================

Promises for Laravel queue jobs

v1.7.0(9mo ago)1912.3k4[1 issues](https://github.com/tochka-developers/queue-promises/issues)PHPPHP 8.2.\*|8.3.\*|8.4.\*CI failing

Since Mar 16Pushed 9mo ago6 watchersCompare

[ Source](https://github.com/tochka-developers/queue-promises)[ Packagist](https://packagist.org/packages/tochka-developers/queue-promises)[ RSS](/packages/tochka-developers-queue-promises/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (10)Dependencies (9)Versions (101)Used By (0)

Queue Promises
==============

[](#queue-promises)

[![Packagist](https://camo.githubusercontent.com/ac28ac8d936a68f25287ddfe2d91417cebe88689b6ccef277d0b22595ced9ff5/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f746f63686b612d646576656c6f706572732f71756575652d70726f6d697365732e737667)](https://packagist.org/packages/tochka-developers/queue-promises)[![Packagist](https://camo.githubusercontent.com/c4367cfd6cf195fe52a3ce55cea7d89aa800b4e5291fc7bd6c66defd9915aaf7/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f746f63686b612d646576656c6f706572732f71756575652d70726f6d697365732e737667)](https://packagist.org/packages/tochka-developers/queue-promises)[![build](https://github.com/tochka-developers/queue-promises/actions/workflows/main.yml/badge.svg)](https://github.com/tochka-developers/queue-promises/actions/workflows/main.yml)[![Psalm coverage](https://camo.githubusercontent.com/534707ac148d0e2eeb2375f0ae195c7e8ce76200611e18270c1d21c50a73cd8d/68747470733a2f2f73686570686572642e6465762f6769746875622f746f63686b612d646576656c6f706572732f71756575652d70726f6d697365732f636f7665726167652e737667)](https://shepherd.dev/github/tochka-developers/queue-promises)[![Psalm level](https://camo.githubusercontent.com/c3ad1d884a2101f915cb9080e353158ec4a055fef501bdbd2c392068e82e0bbe/68747470733a2f2f73686570686572642e6465762f6769746875622f746f63686b612d646576656c6f706572732f71756575652d70726f6d697365732f6c6576656c2e737667)](https://psalm.dev)[![Coverage Status](https://camo.githubusercontent.com/84bd0760336cf00e84ec8d89844c5d9eecce9fec6c9759c2d64b1f0333855ab6/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f746f63686b612d646576656c6f706572732f71756575652d70726f6d697365732f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/tochka-developers/queue-promises)

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
------------

[](#installation)

- Install the package with `composer`:

```
composer require tochka-developers/queue-promises
```

- (Laravel 5.4) Register a `ServiceProvider` in `config/app.php`

```
'providers' => [
    ...
    \Tochka\Queue\Promises\QueuePromisesServiceProvider::class
    ...
]
```

- Publish the configuration:

```
php artisan vendor:publish --provider="Tochka\Queue\Promises\QueuePromisesServiceProvider"
```

- Configure the promise storage in `config/promises.php`.
- Create the promise storage tables:

```
php artisan migrate
```

Usage
-----

[](#usage)

### Creating a Promise

[](#creating-a-promise)

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

```
php artisan make:promise TestPromise
```

### Class details

[](#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.

```
