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

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

webware/command-bus
===================

CommandBus for Mezzio

0.4.0(4mo ago)4787↓50%[1 issues](https://github.com/tyrsson/command-bus/issues)3BSD-3-ClausePHPPHP ~8.2.0 || ~8.3.0 || ~8.4.0 || ~8.5.0CI passing

Since Aug 24Pushed 2mo ago1 watchersCompare

[ Source](https://github.com/tyrsson/command-bus)[ Packagist](https://packagist.org/packages/webware/command-bus)[ Docs](https://github.com/tyrsson/command-bus/discussions)[ RSS](/packages/webware-command-bus/feed)WikiDiscussions 0.5.x Synced 1mo ago

READMEChangelog (4)Dependencies (7)Versions (9)Used By (3)

cmd-bus Documentation
=====================

[](#cmd-bus-documentation)

A Command Bus implementation for Mezzio applications, providing a clean way to handle commands through a middleware pipeline.

Table of Contents
-----------------

[](#table-of-contents)

### Core Components

[](#core-components)

- [CommandBus](docs/commandbus.md) - The main command bus implementation
- [CommandBusInterface](docs/commandbus-interface.md) - Command bus contract
- [MiddlewarePipe](docs/middleware-pipe.md) - Middleware pipeline management
- [MiddlewarePipelineInterface](docs/middleware-pipeline-interface.md) - Pipeline contract
- [ConfigProvider](docs/config-provider.md) - Laminas configuration provider
- [Next](docs/next.md) - Pipeline delegation helper

### Interfaces

[](#interfaces)

- [CommandInterface](docs/command-interface.md) - Command contract
- [CommandHandlerInterface](docs/command-handler-interface.md) - Handler contract
- [MiddlewareInterface](docs/middleware-interface.md) - Middleware contract

### Container Factories

[](#container-factories)

- [CommandBusFactory](docs/container/command-bus-factory.md) - Service factory for CmdBus
- [CommandHandlerMiddlewareFactory](docs/container/command-handler-middleware-factory.md) - Factory for CommandHandlerMiddleware
- [MiddlewarePipeFactory](docs/container/middleware-pipe-factory.md) - Factory for MiddlewarePipe

### Middleware

[](#middleware)

- [PreCommandHandlerMiddleware](docs/middleware/pre-command-handler-middleware.md) - Middleware for pre-processing commands
- [CommandHandlerMiddleware](docs/middleware/command-handler-middleware.md) - Final middleware for command execution
- [PostCommandHandlerMiddleware](docs/middleware/post-command-handler-middleware.md) - Middleware for post-processing results

### Handlers

[](#handlers)

- [EmptyPipelineHandler](docs/handler/empty-pipeline-handler.md) - Default handler for empty pipelines

### Exceptions

[](#exceptions)

- [CommandException](docs/exception/command-exception.md) - Base command exception
- [InvalidConfigurationException](docs/exception/invalid-configuration-exception.md) - Configuration errors
- [NextHandlerAlreadyCalledException](docs/exception/next-handler-already-called-exception.md) - Pipeline state errors
- [ServiceNotFoundException](docs/exception/service-not-found-exception.md) - Service resolution errors

Quick Start
-----------

[](#quick-start)

### Installation

[](#installation)

```
composer require webware/command-bus
```

### Basic Configuration

[](#basic-configuration)

```
// config/config.php
return [
    Webware\CommandBus\ConfigProvider::class => [
        'command_map' => [
            App\Command\CreateUserCommand::class => App\Handler\CreateUserHandler::class,
        ],
        'middleware_pipeline' => [
            ['middleware' => \Webware\CommandBus\Middleware\CommandHandlerMiddleware::class, 'priority' => 1],
        ],
    ],
];
```

### Usage in Mezzio

[](#usage-in-mezzio)

```
// In a request handler or middleware
class UserHandler
{
    public function __construct(
        private \Webware\CommandBus\CmdBusInterface $commandBus
    ) {}

    public function handle(ServerRequestInterface $request): ResponseInterface
    {
        $data = $request->getParsedBody();

        $command = new CreateUserCommand(
            email: $data['email'],
            username: $data['username']
        );

        $user = $this->commandBus->handle($command);

        return new JsonResponse(['user' => $user->toArray()]);
    }
}
```

Architecture Overview
---------------------

[](#architecture-overview)

The cmd-bus library follows these key principles:

1. **Commands** are data objects that implement `CommandInterface`
2. **Handlers** process commands and implement `CommandHandlerInterface`
3. **Middleware** can intercept and potentially modify command processing
4. **Pipeline** manages middleware execution order
5. **Factory classes** integrate with Laminas ServiceManager/ Psr\\Container\\ContainerInterface

Contributing
------------

[](#contributing)

See the project repository for contribution guidelines and development setup instructions.

###  Health Score

42

—

FairBetter than 90% of packages

Maintenance76

Regular maintenance activity

Popularity23

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity48

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 78.6% 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 ~24 days

Recently: every ~36 days

Total

9

Last Release

71d ago

PHP version history (2 changes)0.1.0PHP ~8.2.0 || ~8.3.0 || ~8.4.0

0.3.0PHP ~8.2.0 || ~8.3.0 || ~8.4.0 || ~8.5.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/4d6eed33e61a99f1147789696252f4523130b5035a19eb07e034a7407fd44548?d=identicon)[tyrsson](/maintainers/tyrsson)

---

Top Contributors

[![tyrsson](https://avatars.githubusercontent.com/u/1237487?v=4)](https://github.com/tyrsson "tyrsson (92 commits)")[![renovate[bot]](https://avatars.githubusercontent.com/in/2740?v=4)](https://github.com/renovate[bot] "renovate[bot] (25 commits)")

---

Tags

mezziocommandbuswebware

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[civicrm/civicrm-core

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

728272.9k20](/packages/civicrm-civicrm-core)[symfony/object-mapper

Provides a way to map an object to another object

34885.7k18](/packages/symfony-object-mapper)[xefi/faker-php-laravel

Faker php integration with laravel

1915.1k](/packages/xefi-faker-php-laravel)[aeliot/todo-registrar

Register TODOs from source code in issue tracker

153.0k](/packages/aeliot-todo-registrar)[jildertmiedema/laravel-tactician

Tactician for laravel 8+

105.0k](/packages/jildertmiedema-laravel-tactician)

PHPackages © 2026

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