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

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

ericksonreyes/command-bus
=========================

Simple Command Bus Class for PHP 8

00PHP

Since Mar 12Pushed 3y ago1 watchersCompare

[ Source](https://github.com/ericksonreyes/command-bus)[ Packagist](https://packagist.org/packages/ericksonreyes/command-bus)[ RSS](/packages/ericksonreyes-command-bus/feed)WikiDiscussions master Synced today

READMEChangelogDependenciesVersions (1)Used By (0)

Simple Command Bus for PHP 8
============================

[](#simple-command-bus-for-php-8)

[![Code Coverage](https://github.com/ericksonreyes/command-bus/raw/master/coverage_badge.svg)](https://github.com/ericksonreyes/command-bus/raw/master/coverage_badge.svg)[![Build](https://github.com/ericksonreyes/command-bus/actions/workflows/merge.yaml/badge.svg?branch=master)](https://github.com/ericksonreyes/command-bus/actions/workflows/merge.yaml)

Nothing fancy. I just created my command bus that I've been copy-pasting over and over again. I usually move most of the business or application logic away from framework controllers (MVC) and put it into commands and handlers.

But I don't want to couple the command handler with the framework controller. I want to be able to assign and switch them via a dependency injection library.

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

[](#installation)

```
composer require ericksonreyes/command-bus
```

### Example (Lumen Framework + Symfony Dependency Injection)

[](#example-lumen-framework--symfony-dependency-injection)

Symfony Service Container Configuration

```
services:

  uuid_generator:
    class: App\Services\UuidGenerator

  user_repository:
    class: App\Repositories\UserRepository

  user_registration_service:
    class: Application\Users\Service\UserRegistrationService
    arguments:
    - '@user_repository'
```

Lumen Controller

```
namespace App\Http\Controllers;

use App\Repository\UserRepository;
use Illuminate\Support\Facades\URL;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Illuminate\Routing\Controller as BaseController;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Application\Users\UseCase\RegisterUser;

/**
* Class UserRegistrationController
 * @package App\Http\Controllers
 */
class UserRegistrationController extends BaseController {

    /**
     * @param \Symfony\Component\DependencyInjection\ContainerInterface $container
     * @param \Illuminate\Http\Request $request
     * @return \Illuminate\Http\Response
    */
    public function store(
        ContainerInterface $container,
        Request $request
    ): Response {
        try {
            $url = URL::current();
            $id = $uuidGenerator->generate(prefix: 'user-');
            $uuidGenerator = $container->get('uuid_generator');
            $handler = $container->get('user_registration_service');

            $command = new RegisterUser(
                $id,
                $request->get('email'),
                $request->get('password'),
                $request->get('password_confirmation')
            );
            $handler->handleThis($command);

            return \response([
                '_embedded' => [
                    '_links' => [
                        'self' => [
                            'href' => url("{$url}/{$id}")
                        ]
                    ],
                    'id' => $id
                ]
            ], 201);
        }
        catch (\Exception $exception) {
            $httpCode = 500;
            if ($exception->getCode() >= 400 && $exception->getCode() < 600) {
                $httpCode =$exception->getCode();
            }

            return \response([
                '_error' => [
                    'code' => get_class($exception),
                    'message' => $exception->getMessage()
                ]
            ], $httpCode);
        }
    }

}
```

### Author

[](#author)

- Erickson Reyes ([GitHub](https://github.com/ericksonreyes), [GitLab](https://gitlab.com/ericksonreyes/), [LinkedIn](https://www.linkedin.com/in/ericksonreyes/)and [Packagist](http://packagist.org/users/ericksonreyes/)).

### License

[](#license)

See [LICENSE](LICENSE)

### Gitlab

[](#gitlab)

This project is also available in [GitLab](https://gitlab.com/ericksonreyes/command-bus)

###  Health Score

13

—

LowBetter than 1% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity0

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity23

Early-stage or recently created project

 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.

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/841321?v=4)[Erickson Reyes](/maintainers/ericksonreyes)[@ericksonreyes](https://github.com/ericksonreyes)

---

Top Contributors

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

### Embed Badge

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

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

###  Alternatives

[illuminate/console

The Illuminate Console package.

13046.0M6.5k](/packages/illuminate-console)[styleci/cli

The CLI tool for StyleCI

71470.5k9](/packages/styleci-cli)[winbox/args

Windows command-line formatter

20720.9k21](/packages/winbox-args)[tomatophp/filament-artisan

Simple but yet powerful library for running some artisan commands for FilamentPHP

3275.4k1](/packages/tomatophp-filament-artisan)

PHPackages © 2026

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