PHPackages                             tomwright/commander - 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. tomwright/commander

ActiveLibrary

tomwright/commander
===================

A simple command bus.

1.0.2(10y ago)0345PHP

Since Mar 23Pushed 9y ago1 watchersCompare

[ Source](https://github.com/TomWright/Commander)[ Packagist](https://packagist.org/packages/tomwright/commander)[ RSS](/packages/tomwright-commander/feed)WikiDiscussions master Synced 2mo ago

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

Commander
=========

[](#commander)

[![Build Status](https://camo.githubusercontent.com/1af6ab7a325c08905e90e08b8774c3901472e12e05772bfa58c80ece275045b8/68747470733a2f2f7472617669732d63692e6f72672f546f6d5772696768742f436f6d6d616e6465722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/TomWright/Commander)[![Latest Stable Version](https://camo.githubusercontent.com/82767f498f30fee07c8b5ef4bdd1528b356999ba604152f5e3556592e94985fc/68747470733a2f2f706f7365722e707567782e6f72672f746f6d7772696768742f636f6d6d616e6465722f762f737461626c65)](https://packagist.org/packages/tomwright/commander)[![Total Downloads](https://camo.githubusercontent.com/e997b855d0b69f791a8fa1a96718e7c2eeabc0b460357dee7914f4fb0717b5cb/68747470733a2f2f706f7365722e707567782e6f72672f746f6d7772696768742f636f6d6d616e6465722f646f776e6c6f616473)](https://packagist.org/packages/tomwright/commander)[![Monthly Downloads](https://camo.githubusercontent.com/091ed9dcce68abe3033163c0dd8831ee1f7e21f3f861b3b31c3f889a2d79ec54/68747470733a2f2f706f7365722e707567782e6f72672f746f6d7772696768742f636f6d6d616e6465722f642f6d6f6e74686c79)](https://packagist.org/packages/tomwright/commander)[![Daily Downloads](https://camo.githubusercontent.com/56c9a4ef86a9a6f9114059a88a2e3e65ffb4cde5d3ecea4775d36431ae0e957a/68747470733a2f2f706f7365722e707567782e6f72672f746f6d7772696768742f636f6d6d616e6465722f642f6461696c79)](https://packagist.org/packages/tomwright/commander)[![License](https://camo.githubusercontent.com/065297a32a71a7283c0d19d98e7b75c46c4d351b20309c0b8b1ccf58c2114105/68747470733a2f2f706f7365722e707567782e6f72672f746f6d7772696768742f636f6d6d616e6465722f6c6963656e73652e737667)](https://packagist.org/packages/tomwright/commander)

Usage
-----

[](#usage)

You need a Command and a CommandHandler.

Let's say we have a command class stored in app/commanding/command/RegisterUserCommand.php.

```
namespace App\Commanding\Command;

class RegisterUserCommand extends \TomWright\Commander\Command\Command
{
	protected $username;
    protected $password;

    public function setUsername($username)
    {
    	$this->username = $username;
    }

    public function getUsername()
    {
    	return $this->username;
    }

    public function setPassword($password)
    {
        $this->password = $password;
    }

    public function getPassword()
    {
        return $this->password;
    }
}
```

Let's also assume we have a command handler class stored in app/commanding/handler/RegisterUserHandler.php.

```
namespace App\Commanding\Handler;

class RegisterUserHandler implements \TomWright\Commander\Handler\HandlerInterface
{
    public function handle(\TomWright\Commander\Command\CommandInterface $command)
    {
    	echo "Registering user \"{$command->getUsername()}\" with password \"{$command->getPassword()}\".";
    }
}
```

Now we need to add a Command Handler namespace so as the CommandBus knows where to look for the handlers.

```
$bus = \TomWright\Commander\CommandBus::getInstance();
$bus->addHandlerNamespace('\\App\\Commanding\\Handler');
```

Now whenever we want to register a new user, all we have to do is the following:

```
$bus = \TomWright\Commander\CommandBus::getInstance();
$command = new \App\Commanding\Command\RegisterUserCommand();
$command->setUsername('Some user');
$command->setPassword('Somepassword123');
$bus->handle($command);
```

Remember - a Command is an **action** and not a **notification**. If you are looking for a notification/event handler see [TomWright/Eventing](https://github.com/TomWright/Eventing).

###  Health Score

29

—

LowBetter than 59% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity65

Established project with proven stability

 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

Every ~0 days

Total

3

Last Release

3704d ago

### Community

Maintainers

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

---

Top Contributors

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

### Embed Badge

![Health badge](/badges/tomwright-commander/health.svg)

```
[![Health](https://phpackages.com/badges/tomwright-commander/health.svg)](https://phpackages.com/packages/tomwright-commander)
```

###  Alternatives

[timacdonald/log-fake

A drop in fake logger for testing with the Laravel framework.

4235.9M56](/packages/timacdonald-log-fake)[jasonmccreary/laravel-test-assertions

A set of helpful assertions when testing Laravel applications.

3513.9M32](/packages/jasonmccreary-laravel-test-assertions)[ergebnis/phpunit-slow-test-detector

Provides facilities for detecting slow tests in phpunit/phpunit.

1468.1M72](/packages/ergebnis-phpunit-slow-test-detector)[typo3/testing-framework

The TYPO3 testing framework provides base classes for unit, functional and acceptance testing.

675.0M775](/packages/typo3-testing-framework)[robiningelbrecht/phpunit-pretty-print

Prettify PHPUnit output

76460.0k15](/packages/robiningelbrecht-phpunit-pretty-print)[webmozarts/strict-phpunit

Enables type-safe comparisons of objects in PHPUnit

31252.7k5](/packages/webmozarts-strict-phpunit)

PHPackages © 2026

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