PHPackages                             weew/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. [CLI &amp; Console](/categories/cli)
4. /
5. weew/commander

ActiveLibrary[CLI &amp; Console](/categories/cli)

weew/commander
==============

Simple command bus.

v2.2.1(9y ago)034911MITPHP

Since Nov 11Pushed 9y ago1 watchersCompare

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

READMEChangelogDependencies (4)Versions (11)Used By (1)

Simple command bus
==================

[](#simple-command-bus)

[![Build Status](https://camo.githubusercontent.com/2cc6adcde445c204f3fb81e82616982abdcbc4cc65559ee1eb59c9984100b338/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f776565772f636f6d6d616e6465722e737667)](https://travis-ci.org/weew/commander)[![Code Quality](https://camo.githubusercontent.com/ad12387d448eb05a76b5f80ca3def8df7ac0a9b65e89003b9daf69cdebfcb526/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f776565772f636f6d6d616e6465722e737667)](https://scrutinizer-ci.com/g/weew/commander)[![Test Coverage](https://camo.githubusercontent.com/4ad27941a20fa2fb7eb7c8b1779c0327ab131a827161cddb8518e1001d5ca685/68747470733a2f2f696d672e736869656c64732e696f2f636f766572616c6c732f776565772f636f6d6d616e6465722e737667)](https://coveralls.io/github/weew/commander)[![Version](https://camo.githubusercontent.com/e88bad042666dde5728e84a1260a639de24ca34f20b8f083ff00af078992e7d9/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f776565772f636f6d6d616e6465722e737667)](https://packagist.org/packages/weew/commander)[![Licence](https://camo.githubusercontent.com/8cc89c3c289dee35db9dd110a6ca50ec862070fb83a683b4458bc8927ba56673/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f776565772f636f6d6d616e6465722e737667)](https://packagist.org/packages/weew/commander)

Table of contents
-----------------

[](#table-of-contents)

- [Installation](#installation)
- [Introduction](#introduction)
- [Commands](#commands)
- [Registering command handlers](#registering-command-handlers)
- [Dispatching commands](#dispatching-commands)
- [Existing container integrations](#existing-container-integrations)

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

[](#installation)

`composer require weew/commander`

Introduction
------------

[](#introduction)

Commander is a simple message bus. It allows you to register command handlers and to dispatch commands. The main reason to use such an abstraction is to decouple components and dependencies. The caller never knows who will handle a command after all. All he knows is a set of contracts that both sides have to fulfill.

Commands
--------

[](#commands)

A command has no restrictions. You can use almost everything as a command. It is recommended to create simple transfer/value objects and use them as commands. A command is basically a contract between the caller and the handler.

Registering command handlers
----------------------------

[](#registering-command-handlers)

To be able to dispatch commands to handlers, commander has to know who is responsible for each command. That is why you have have to register a handler for each command. A handler can be a callable or a class / instance that implements method `handle($command)`.

First let's create a very basic command, a handler and a result.

```
class FooCommandHandler {
    public function handle($command) {
        return new FooResult();
    }
}

class FooCommand {
    public function __construct($foo, $bar) {}
}
class FooResult {}
```

Now comes the command registration.

```
$commander = new Commander();
$commander->register(FooCommand::class, FooCommandHandler::class);
```

Dispatching commands
--------------------

[](#dispatching-commands)

After you have registered your commands and handlers you can invoke them from anywhere within you application.

```
$result = $commander->dispatch(new FooCommand('foo', 'bar'));
```

Existing container integrations
-------------------------------

[](#existing-container-integrations)

There is an integration available for the [weew/container](https://github.com/weew/container) container. See [weew/commander-container-aware](https://github.com/weew/commander-container-aware).

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity69

Established project with proven stability

 Bus Factor1

Top contributor holds 50% 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 ~28 days

Recently: every ~61 days

Total

10

Last Release

3585d ago

Major Versions

v0.0.3 → v1.0.02015-11-16

v1.2.0 → v2.0.02016-03-03

### Community

Maintainers

![](https://www.gravatar.com/avatar/10b2b854b5829dd13a15967c000ed2119b5faef67aca24d94c653c8ac550d85e?d=identicon)[weew](/maintainers/weew)

---

Top Contributors

[![maximkott](https://avatars.githubusercontent.com/u/2686062?v=4)](https://github.com/maximkott "maximkott (1 commits)")[![mikeSimonson](https://avatars.githubusercontent.com/u/907613?v=4)](https://github.com/mikeSimonson "mikeSimonson (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[wp-cli/wp-cli

WP-CLI framework

5.0k17.2M320](/packages/wp-cli-wp-cli)[consolidation/annotated-command

Initialize Symfony Console commands from annotated command class methods.

22569.8M19](/packages/consolidation-annotated-command)[chi-teck/drupal-code-generator

Drupal code generator

26947.8M5](/packages/chi-teck-drupal-code-generator)[seld/cli-prompt

Allows you to prompt for user input on the command line, and optionally hide the characters they type

24725.8M17](/packages/seld-cli-prompt)[illuminate/console

The Illuminate Console package.

12944.1M5.1k](/packages/illuminate-console)[php-tui/php-tui

Comprehensive TUI library heavily influenced by Ratatui

589747.0k6](/packages/php-tui-php-tui)

PHPackages © 2026

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