2017 © Pedro Peláez
 

library commander

Command Bus abstraction for PHP.

image

robotusers/commander

Command Bus abstraction for PHP.

  • Wednesday, October 11, 2017
  • by robertpustulka
  • Repository
  • 1 Watchers
  • 2 Stars
  • 1,340 Installations
  • PHP
  • 0 Dependents
  • 1 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 51 % Grown

The README.md

Commander

Software License Build Status codecov, (*1)

Command Bus abstraction for PHP., (*2)

Installation

composer require robotusers/commander

Command Bus abstraction

This library provides a CommandBusInterface which a command bus should implement., (*3)

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);
        $this->handleCommand($command);
        ...
   }

}

Adapters

The library provides adapters for the most common command bus implementations., (*4)

Tactician

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

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

$controller->setCommandBus($adapter);

SimpleBus/MessageBus

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

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

$controller->setCommandBus($adapter);

PSB - ProophServiceBus

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

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

$controller->setCommandBus($adapter);

Writing a custom adapter

You can write your custom adapter. The adapter must implement Robotusers\Commander\CommandBusInterface., (*5)

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

The Versions