Command Bus abstraction for PHP.

0.3.0 2021-03-23 11:08 UTC

This package is auto-updated.

Last update: 2023-03-23 15:30:58 UTC


Software License Build Status codecov

Command Bus abstraction for PHP.


composer require robotusers/commander

Command Bus abstraction

This library provides a CommandBusInterface which a command bus should implement.

Using the command bus

use Robotusers\Commander\CommandBusAwareInterface;
use Robotusers\Commander\CommandBusAwareTrait;

class OrdersController implements CommandBusAwareInterface
   use CommandBusAwareTrait;

   public function makeOrder()
        $command = new MakeOrderCommand($data);



The library provides adapters for the most common command bus implementations.


composer require league/tactician
use League\Tactician\CommandBus;
use Robotusers\Commander\Adapter\TacticianAdapter;

$commandBus = new CommandBus($middleware);
$adapter = new TacticianAdapter($commandBus);



composer require simple-bus/message-bus
use Robotusers\Commander\Adapter\SimpleBusAdapter;
use SimpleBus\Message\Bus\Middleware\MessageBusSupportingMiddleware;

$commandBus = new MessageBusSupportingMiddleware();
$adapter = new SimpleBusAdapter($commandBus);


PSB - ProophServiceBus

composer require prooph/service-bus
use Prooph\ServiceBus\CommandBus;
use Robotusers\Commander\Adapter\ServiceBusAdapter;

$commandBus = new CommandBus();
$adapter = new ServiceBusAdapter($commandBus);


Writing a custom adapter

You can write your custom adapter. The adapter must implement Robotusers\Commander\CommandBusInterface.

class MyAdapter implements CommandBusInterface
    public function handle($command)
        //handle a command