Search by

A dead simple command bus for PHP

Package info

codeberg.org/scripthoodie/cmdbus

Issues

pkg:composer/scripthoodie/cmdbus

Statistics

Installs: 10

Dependents: 0

Suggesters: 0

v1.0.1 2026-10-18 00:31 UTC

This package is auto-updated.

Last update: 2026-10-17 19:04:05 UTC


README

cmdbus logo

PHP PHPStan Packagist version Codeberg License

A dead simple command bus for PHP

cmdbus dispatches commands to handlers. It's easy to use and bundled with features such as middlewares and handler locators.

Installation

Install the latest version with:

composer require scripthoodie/cmdbus

cmdbus requires PHP 8.4 or above.

Basic usage

<?php

use ScriptHoodie\CmdBus\Command;
use ScriptHoodie\CmdBus\CmdBus;
use ScriptHoodie\CmdBus\Middlewares\LogMiddleware;

$bus = new CmdBus();

$bus->addHandler('product.create', function (string $name, int $price) {
    // ...your application logic
});

$bus->addMiddleware(new LogMiddleware($logger), 'product.*');

$productId = $bus->handle(new Command('product.create', [
    'name' => 'Hoodie',
    'price' => 42,
]));

// handle() returns whatever the handler returned

Documentation

The full documentation lives in the docs directory:

Submitting bugs and feature requests

Bugs and feature requests are tracked on Codeberg; see https://codeberg.org/scripthoodie/cmdbus/issues for the repository link.

Contributing

See CONTRIBUTING.md for the development environment.

License

cmdbus is licensed under the GPL-3.0-or-later License — see the LICENSE file for details.