PHPackages                             open-solid/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. open-solid/bus

ActiveLibrary

open-solid/bus
==============

Simple Bus Component

v1.1.4(1y ago)34.3k↑41%3MITPHPPHP &gt;=8.2

Since Apr 17Pushed 1y ago1 watchersCompare

[ Source](https://github.com/open-solid/bus)[ Packagist](https://packagist.org/packages/open-solid/bus)[ RSS](/packages/open-solid-bus/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (8)Versions (16)Used By (3)

Message Bus Component
=====================

[](#message-bus-component)

A message bus component is essential in modern applications for managing communication between different parts of the system. It acts as a central hub that routes messages between services, ensuring decoupled and scalable architecture. This allows individual components to interact without needing to know the specifics of each other, simplifying development and maintenance.

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

[](#installation)

```
composer require open-solid/bus
```

Usage
-----

[](#usage)

### Dispatching Message with the Bus

[](#dispatching-message-with-the-bus)

Think of the "bus" as a mail delivery system for your messages. It follows a specific path, decided by some rules (middleware), to send your message and handle it.

Here's a snippet on how to set it up and dispatch a message:

```
use App\Message\MyMessage;
use OpenSolid\Bus\Handler\MessageHandlersLocator;
use OpenSolid\Bus\Middleware\HandlingMiddleware;
use OpenSolid\Bus\NativeMessageBus;

// This is your custom function that does something when a message arrives.
$handler = function (MyMessage $message): mixed {
    // Do stuff with the message here...
};

// Setting up the bus with a middleware that knows who handles the message.
$bus = new NativeMessageBus([
    new HandlingMiddleware(new MessageHandlersLocator([
        MyMessage::class => [$handler], // Maps messages to handlers.
    ])),
]);

// Send a message using the bus.
$bus->dispatch(new MyMessage());
```

### Handling Messages

[](#handling-messages)

A "message handler" is what does the work when a message arrives. It can be a simple function or a method in a class. Here's how you set one up:

```
use App\Message\MyMessage;

class MyMessageHandler
{
    public function __invoke(MyMessage $message): mixed
    {
        // Process the message here...
    }
}
```

### Middleware

[](#middleware)

Middleware are helpers that perform tasks before and after your message is handled. They operate at the bus level, meaning they handle all messages dispatched through the message bus they are linked to.

Here's how to create one:

```
use OpenSolid\Bus\Envelope\Envelope;
use OpenSolid\Bus\Middleware\Middleware;
use OpenSolid\Bus\Middleware\NextMiddleware;

class MyMiddleware implements Middleware
{
    public function handle(Envelope $envelope, NextMiddleware $next): void
    {
        // Do something before the message handler works.

        $next->handle($envelope); // Call the next middleware

        // Do something after the message handler is done.
    }
}
```

### Decorators

[](#decorators)

Decorators are helpers that perform tasks before and after your message is handled. Unlike Middleware, decorators operate at the handler level, allowing you to modify or enhance specific handlers without changing their actual code.

Check this out in [decorator](https://github.com/yceruto/decorator) and [decorator-bundle](https://github.com/yceruto/decorator-bundle) packages.

Framework Integration
---------------------

[](#framework-integration)

- [cqs-bundle](https://github.com/open-solid/cqs-bundle) - Symfony bundle for Command-Query buses.
- [domain-event-bundle](https://github.com/open-solid/domain-event-bundle) - Symfony bundle for Event bus.

License
-------

[](#license)

This tool is available under the [MIT License](LICENSE), which means you can use it pretty freely in your projects.

###  Health Score

38

—

LowBetter than 85% of packages

Maintenance39

Infrequent updates — may be unmaintained

Popularity27

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity61

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 ~17 days

Recently: every ~28 days

Total

15

Last Release

521d ago

### Community

Maintainers

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

---

Top Contributors

[![yceruto](https://avatars.githubusercontent.com/u/2028198?v=4)](https://github.com/yceruto "yceruto (66 commits)")

---

Tags

cqsmessage-busmessengerphp

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/open-solid-bus/health.svg)

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

###  Alternatives

[laravel/framework

The Laravel Framework.

34.7k509.9M17.0k](/packages/laravel-framework)[symfony/cache

Provides extended PSR-6, PSR-16 (and tags) implementations

4.2k348.9M2.5k](/packages/symfony-cache)[cakephp/cakephp

The CakePHP framework

8.8k18.5M1.6k](/packages/cakephp-cakephp)[symfony/mailer

Helps sending emails

1.6k368.1M955](/packages/symfony-mailer)[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.4k5.6M651](/packages/sylius-sylius)[sulu/sulu

Core framework that implements the functionality of the Sulu content management system

1.3k1.3M152](/packages/sulu-sulu)

PHPackages © 2026

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