Search by

gember / message-bus-symfony

jerowork

Gember Event Sourcing Message Bus adapter based on symfony/messenger

Package info

github.com/GemberPHP/message-bus-symfony

pkg:composer/gember/message-bus-symfony

Statistics

Installs: 1 264

Dependents: 2

Suggesters: 0

Stars: 1

Open Issues: 0

0.12.5 2026-10-30 14:59 UTC

README

Build Status Software License PHP Version

Gember Event Sourcing Message Bus adapter based on symfony/messenger.

All external dependencies in Gember Event Sourcing are organized into separate packages, making it easy to swap out a vendor adapter for another.

Installation

Install with Composer:

composer require gember/message-bus-symfony

Configuration

Bind SymfonyEventBus to the EventBus interface and SymfonyCommandBus to the CommandBus interface in your service definitions.

Examples

Vanilla PHP

use Gember\MessageBusSymfony\SymfonyCommandBus;
use Gember\MessageBusSymfony\SymfonyEventBus;
use Symfony\Component\Messenger\Handler\HandlersLocator;
use Symfony\Component\Messenger\MessageBus;
use Symfony\Component\Messenger\Middleware\HandleMessageMiddleware;

$eventBus = new SymfonyEventBus(
    new MessageBus([ // An event bus configuration of your choice
        new HandleMessageMiddleware(new HandlersLocator([
            SomeEvent::class => [new SomeEventSubscriber()], // callables
            // ...
        ]), allowNoHandlers: true), // events without handlers are normal
    ]),
);

$commandBus = new SymfonyCommandBus(
    new MessageBus([ // A command bus configuration of your choice
        new HandleMessageMiddleware(new HandlersLocator([
            SomeCommand::class => [new SomeCommandHandler()],
            // ...
        ])),
    ]),
);

Symfony

It is recommended to use the Symfony bundle to configure Gember Event Sourcing. With this bundle, the adapters are automatically set as the default for the event bus and command bus.

If you're not using the bundle, you can bind them directly to the EventBus and CommandBus interfaces.

Gember\DependencyContracts\Util\Messaging\MessageBus\EventBus:
  class: Gember\MessageBusSymfony\SymfonyEventBus
  arguments:
    - '@event.bus' # or any other defined Symfony event bus

Gember\DependencyContracts\Util\Messaging\MessageBus\CommandBus:
  class: Gember\MessageBusSymfony\SymfonyCommandBus
  arguments:
    - '@command.bus' # or any other defined Symfony command bus