PHP Enterprise Service Bus Implementation supporting CQRS and DDD

Installs: 1 823

Dependents: 7

Stars: 37

Watches: 5

Forks: 4

Open Issues: 6

Language: PHP

v3.2 2015-05-23 22:25 UTC


PHP 5.5+ Lightweight Service Bus Facade supporting CQRS and Microservices

Build Status

Message API

prooph/service-bus is a lightweight messaging facade sitting in front of your model. The idea is that the API of your model is defined through messages.

  1. Command messages describe the actions your model can handle.
  2. Event messages describe things that happened while your model handled a command.
  3. Query messages describe available information that can be fetched from your model.

prooph/service-bus shields your model. Data input and output ports become irrelevant and no longer influence the business logic. I'm looking at you Hexagonal Architecture.

prooph/service-bus decouples your model from any framework except prooph/service-bus of course :-). You can use a web framework like Zend, Symfony, Laravel and co. to handle http requests and pass them via prooph/service-bus to your model but you can also receive the same messages via CLI or from a messaging infrastructure like RabbitMQ or Beanstalkd.



You can install prooph/service-bus via composer by adding "prooph/service-bus": "~3.0" as requirement to your composer.json.

Quick Start

The simplest way to get started is to set up one of the message buses provided by prooph/service-bus.


use Prooph\ServiceBus\CommandBus;
use Prooph\ServiceBus\Example\Command\EchoText;
use Prooph\ServiceBus\InvokeStrategy\CallbackStrategy;
use Prooph\ServiceBus\Router\CommandRouter;

$commandBus = new CommandBus();

$router = new CommandRouter();

//Register a callback as CommandHandler for the EchoText command
    ->to(function (EchoText $aCommand) {
        echo $aCommand->getText();

//Expand command bus with the router plugin

//Expand command bus with the callback invoke strategy
$commandBus->utilize(new CallbackStrategy());

//We create a new Command
$echoText = EchoText::fromString('It works');

//... and dispatch it

//Output should be: It works


ZF2 Integration

prooph/proophessor seamlessly integrates prooph/service-bus with a ZF2 application.



Please feel free to fork and extend existing or add new features and send a pull request with your changes! To establish a consistent code quality, please provide unit tests for all your changes and may adapt the documentation.