PHPackages                             keystone/tactician-deferred - 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. keystone/tactician-deferred

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

keystone/tactician-deferred
===========================

A Tactician middleware to allow commands to be handled asynchronously

0.1.0(9y ago)019MITPHPPHP &gt;=5.6

Since Dec 30Pushed 9y ago1 watchersCompare

[ Source](https://github.com/keystonephp/tactician-deferred)[ Packagist](https://packagist.org/packages/keystone/tactician-deferred)[ RSS](/packages/keystone-tactician-deferred/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (5)Versions (2)Used By (0)

Deferred Commands with Tactician and Keystone Queue
===================================================

[](#deferred-commands-with-tactician-and-keystone-queue)

[![Build Status](https://camo.githubusercontent.com/7b3190e636aae88738ecd9555dc6b352145e02f88619e3102d36105e5aa154fe/68747470733a2f2f7472617669732d63692e6f72672f6b657973746f6e657068702f74616374696369616e2d64656665727265642e706e67)](https://travis-ci.org/keystonephp/tactician-deferred)

A Tactician middleware to allow commands to be handled asynchronously using [Keystone Queue](https://github.com/keystonephp/queue).

Features:

- Unobtrusive API to allow asynchronous handling of commands.
- Publish command messages to any queue.
- Commands can be retried on failure.

Installation
------------

[](#installation)

Install via Composer

```
composer require --dev keystone/tactician-deferred
```

Usage
-----

[](#usage)

Create a command class that implemented `DeferrableCommand` to tell the middleware to handle it asynchronously.

```
use Keystone\Tactician\Deferred\Command\DeferrableCommand;

class SendWelcomeCommand implements DeferrableCommand
{
    public $email;
    public $name;

    public function __construct(string $email, string $name)
    {
        $this->email = $email;
        $this->name = $name;
    }

    public function getKey(): string
    {
        // The command key is used to determine which queue to publish to.
        return 'email';
    }
}
```

Create a command handler as normal using your desired inflector method.

```
class SendWelcomeHandler
{
    public function handle(SendWelcomeCommand $command)
    {
        // Send the welcome
    }
}
```

When the command is handled by the command bus the middleware will publish a message to the queue and halt the handler. The message will then be received by the consumer and the worker will delegate the command to the command bus. Since the command will be serialized within the queue it's properties should be simple scalar values.

```
$commandBus = new CommandBus([new DeferredMiddleware(...), new CommandHandlerMiddleware(...)]);
$commandBus->handle(new SendWelcomeCommand('ben@flowerpots.com', 'Ben'));
```

Consume the messages in a long running process (see [Keystone Queue](https://github.com/keystonephp/queue) for more information).

```
use Keystone\Queue\Consumer;
use Keystone\Queue\Provider;

$provider = new Provider(...);
$consumer = new Consumer($provider, ...);
// The consumer will poll the queue for new messages and process them.
$consumer->consume();
```

When the middleware is not configured the command will be handled synchronously as normal, which can be useful for testing without worrying about asynchronous processes in development environments.

Credits
-------

[](#credits)

- [Tom Graham](https://github.com/tompedals) (maintainer)

License
-------

[](#license)

Released under the MIT Licence. See the bundled LICENSE file for details.

###  Health Score

22

—

LowBetter than 23% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity48

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

3416d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/0108faaeaf073146f428b1f04b42ba469d97bf2a9d14f31183a2b541f3de8197?d=identicon)[tompedals](/maintainers/tompedals)

---

Top Contributors

[![tompedals](https://avatars.githubusercontent.com/u/6132043?v=4)](https://github.com/tompedals "tompedals (4 commits)")

---

Tags

asynchronousdeferrablequeuetactician

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/keystone-tactician-deferred/health.svg)

```
[![Health](https://phpackages.com/badges/keystone-tactician-deferred/health.svg)](https://phpackages.com/packages/keystone-tactician-deferred)
```

###  Alternatives

[league/geotools

Geo-related tools PHP 7.3+ library

1.4k5.3M26](/packages/league-geotools)[amphp/parser

A generator parser to make streaming parsers simple.

14952.8M16](/packages/amphp-parser)[amphp/serialization

Serialization tools for IPC and data storage in PHP.

13451.1M18](/packages/amphp-serialization)[deliciousbrains/wp-background-processing

WP Background Processing can be used to fire off non-blocking asynchronous requests or as a background processing tool, allowing you to queue tasks.

1.1k409.8k6](/packages/deliciousbrains-wp-background-processing)[react/async

Async utilities and fibers for ReactPHP

2238.8M170](/packages/react-async)[amphp/pipeline

Asynchronous iterators and operators.

7432.7M34](/packages/amphp-pipeline)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
