innmind/command-bus

This package is abandoned and no longer maintained. No replacement package was suggested.

Command Bus library

4.2.0 2021-02-14 15:00 UTC

This package is auto-updated.

Last update: 2022-12-12 08:11:44 UTC


README

Build Status codecov Type Coverage

Simple library to route a command to its handler, the interface allows you to compose buses to add capabilities. Each handler must be a callable.

Installation

composer require innmind/command-bus

Example

use function Innmind\CommandBus\bootstrap;
use Innmind\Immutable\Map;

class MyCommand {}

$echo = function(MyCommand $command) {
    echo 'foo';
};

$handle = bootstrap()['bus'](
    Map::of('string', 'callable')
        (MyCommand::class, $echo)
);

$handle(new MyCommand); //prints 'foo' and return null;