PHPackages                             rezzza/command-bus - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. rezzza/command-bus

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

rezzza/command-bus
==================

Easy command bus

3.3.2(8y ago)940.1k10[1 issues](https://github.com/rezzza/command-bus/issues)1MITPHPPHP &gt;=5.5.0

Since Oct 6Pushed 7y ago6 watchersCompare

[ Source](https://github.com/rezzza/command-bus)[ Packagist](https://packagist.org/packages/rezzza/command-bus)[ Docs](https://github.com/rezzza/command-bus)[ RSS](/packages/rezzza-command-bus/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (6)Versions (13)Used By (1)

Rezzza\\CommandBus
------------------

[](#rezzzacommandbus)

[![Build Status](https://camo.githubusercontent.com/8248ffa6a72db489301e0386c230a4464f8e1cd44b8da51655d0b3c6276e0b3d/68747470733a2f2f7472617669732d63692e6f72672f72657a7a7a612f636f6d6d616e642d6275732e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/rezzza/command-bus)

Light command bus.

Installation
============

[](#installation)

`composer.json`:

```
    "rezzza/command-bus": "~2.0"
```

Command
=======

[](#command)

Commands must implements an interface `Rezzza\CommandBus\Domain\CommandInterface`, it should be value object, example:

```
class ShortenUrlCommand
{
    private $longUrl;

    public function __construct($longUrl)
    {
        $this->longUrl = $longUrl;
    }

    public function getLongUrl()
    {
        return $this->longUrl;
    }
}
```

Command Handlers
================

[](#command-handlers)

A command handler will be called by the command bus when it handle command.

The handler could be:

```
- A callable (\Closure or a callback)
- An object. In example of ShortenUrlCommand, the bus will execute `$object->shortenUrl($command)`

```

Command bus
===========

[](#command-bus)

It'll find a command handler then handle the command. We provide at this moment three command bus:

```
- Direct (synchronous)
- Redis (asynchronous)
- Rabbit (asynchronous)
- Implement your own command bus with `\Rezzza\CommandBus\Domain\CommandBusInterface`

```

You can see `examples` to see them in action.

Fail Strategies
===============

[](#fail-strategies)

When the bus handle the command, and the command handler fail, you may want to re-queue the command to be executed later.

```
- RetryThenFailStrategy: The command is requeued in a `Retry` queue, you'll be able to consume this queue and configure how many time you want to execute it before it goes to a `Fail` queue. Look at `examples/redis_worker.php` example to understand how it work.
- RequeueStrategy: The command is requeued
- NoneStrategy: The command will not being requeued.
- Your own strategy with `Rezzza\CommandBus\Domain\Consumer\FailStrategy\FailStrategyInterface`

```

Consumer
========

[](#consumer)

In your console command, you can use a consumer to handle asynchronous commands. For example with redis, you'll do

```
do {
    $redis    = new \Redis();
    $redis->connect('......');

    $handlerLocator = new Rezzza\CommandBus\Infra\Handler\MemoryHandlerLocator();
    // add some handlers ...
    $directBus         = new Rezzza\CommandBus\Infra\Provider\Direct\DirectBus($handlerLocator);
    $failStrategy      = new Rezzza\CommandBus\Domain\Consumer\FailStrategy\NoneStrategy();
    $redisKeyGenerator = new CommandBus\Infra\Provider\Redis\RedisKeyGenerator();
    $serializer        = new CommandBus\Infra\Serializer\NativeSerializer();

    $consumer = new Rezzza\CommandBus\Domain\Consumer\Consumer(
        new Rezzza\CommandBus\Infra\Provider\Redis\RedisConsumerProvider($redis, $redisKeyGenerator, $serializer),
        $directBus,
        $failStrategy
    );

    $consumer->consume('FooCommand');
    sleep(1); // yep ...
} while (true);
```

Examples are the best documentation, look at `examples` directory.

###  Health Score

38

—

LowBetter than 85% of packages

Maintenance18

Infrequent updates — may be unmaintained

Popularity36

Limited adoption so far

Community21

Small or concentrated contributor base

Maturity65

Established project with proven stability

 Bus Factor2

2 contributors hold 50%+ of commits

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

Every ~57 days

Recently: every ~73 days

Total

12

Last Release

3245d ago

Major Versions

v1.1.2 → v2.02016-01-15

v2.0.1 → v3.0.02016-02-22

### Community

Maintainers

![](https://www.gravatar.com/avatar/47c3006a9e7662031ee9d3fa064238fef88479fd7d60f18dd47f038fbbd7dc5a?d=identicon)[steph\_py](/maintainers/steph_py)

---

Top Contributors

[![stephpy](https://avatars.githubusercontent.com/u/232744?v=4)](https://github.com/stephpy "stephpy (27 commits)")[![tyx](https://avatars.githubusercontent.com/u/245494?v=4)](https://github.com/tyx "tyx (23 commits)")[![shouze](https://avatars.githubusercontent.com/u/54712?v=4)](https://github.com/shouze "shouze (5 commits)")[![mtrudu](https://avatars.githubusercontent.com/u/10370955?v=4)](https://github.com/mtrudu "mtrudu (1 commits)")[![Ph3nol](https://avatars.githubusercontent.com/u/183984?v=4)](https://github.com/Ph3nol "Ph3nol (1 commits)")[![ScullWM](https://avatars.githubusercontent.com/u/1017746?v=4)](https://github.com/ScullWM "ScullWM (1 commits)")

---

Tags

commandbus

### Embed Badge

![Health badge](/badges/rezzza-command-bus/health.svg)

```
[![Health](https://phpackages.com/badges/rezzza-command-bus/health.svg)](https://phpackages.com/packages/rezzza-command-bus)
```

###  Alternatives

[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.4k5.6M651](/packages/sylius-sylius)[shopware/platform

The Shopware e-commerce core

3.3k1.5M3](/packages/shopware-platform)[sulu/sulu

Core framework that implements the functionality of the Sulu content management system

1.3k1.3M152](/packages/sulu-sulu)[civicrm/civicrm-core

Open source constituent relationship management for non-profits, NGOs and advocacy organizations.

728272.9k20](/packages/civicrm-civicrm-core)[shopware/core

Shopware platform is the core for all Shopware ecommerce products.

595.2M386](/packages/shopware-core)[ec-cube/ec-cube

EC-CUBE EC open platform.

78527.0k1](/packages/ec-cube-ec-cube)

PHPackages © 2026

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