PHPackages                             proyectotau/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. proyectotau/command-bus

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

proyectotau/command-bus
=======================

Minimalist implementation of CommandBus pattern for test purpose only

1.2.0(4y ago)061GPLv2PHPCI failing

Since Mar 21Pushed 4y agoCompare

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

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

CommandBus
==========

[](#commandbus)

Minimalist implementation of CommandBus pattern for test purpose only

According to (it remembers remotelly to)
========================================

[](#according-to-it-remembers-remotelly-to)

Install
=======

[](#install)

Insert official repository in your `composer.json`

```
    "repositories": [
        {
            "type": "vcs",
            "url": "https://github.com/proyectotau/command-bus.git"
        }
    ],
```

Require it by composer

```
   composer -vvv require proyectotau/command-bus:dev-master
```

Usage
=====

[](#usage)

Create a `CommandHandler` class

```
class CommandHandler {

	function handler($cmd){
		// run your task here
		// you can get public var from cmd if it is an object
	}
}
```

Make a `CommandBus` class

```
	$cmdbus = new CommandBus();
```

And `bind` command to that command handler

```
	$cmdbus->bind('MyCommand', $handler);
```

Command can be an object with parameters

```
	$cmdobj = new CommandObject(true, 1, []);
	$cmdbus->bind($cmdobj, $handler);
```

Finally, `dispatch` command

```
	$cmdbus->dispatch('MyCommand');
```

or

```
	$cmdbus->dispatch($cmdobj);
```

As a result, handler method will be invoke receiving command as an argument. If it is an object, you could get constructor's params. Let command be an object like this:

```
class CommandObject {
	public $param1;
	public $param2;
	public $param3;

	function __constructor($param1, $param2, $param3) {
		$this->param1 = $param1;
		$this->param2 = $param2;
		$this->param3 = $param3;
	}
}
```

You can pick up them

```
function handler($cmd){
		$this->param1 = $cmd->param1;
		$this->param2 = $cmd->param2;
		$this->param3 = $cmd->param3;
	}
```

Tests
=====

[](#tests)

You can run tests like this

```
vendor/bin/phpunit --color --testdox tests/CommandBusTest.php
```

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community6

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

1518d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/b8fd65f71e7e47a10768b9a35c6910ec4a1df36f4573ef2ede62525980873fcf?d=identicon)[proyectotau](/maintainers/proyectotau)

---

Top Contributors

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

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

PHPackages © 2026

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