Skip to content

About

IMPLEMENTATION - CQRS with League Tactician

Resources

Contributing

Stars

2 stars

Watchers

1 watching

Forks

Repository files navigation

PHP version Latest Version License

Build Status Style Check Code Quality Code Coverage

Total Downloads Monthly Downloads

CQRS with Tactician

CQRS implementation with League Tactician

Installation

Composer

composer require phpgears/cqrs-tactician

Usage

Require composer autoload file

require './vendor/autoload.php';

Commands Bus

use Gears\CQRS\Tactician\CommandBus;
use Gears\CQRS\Tactician\CommandHandlerMiddleware;
use League\Tactician\CommandBus as TacticianBus;
use League\Tactician\Handler\Locator\InMemoryLocator;
use League\Tactician\Plugins\LockingMiddleware;

$commandToHandlerMap = [];
        
$tacticianBus = new TacticianBus([
    new LockingMiddleware(),
    new CommandHandlerMiddleware(new InMemoryLocator($commandToHandlerMap)),
]);

$commandBus = new CommandBus($tacticianBus);

/** @var \Gears\CQRS\Command $command */
$commandBus->handle($command);

Query Bus

use Gears\CQRS\Tactician\QueryBus;
use Gears\CQRS\Tactician\QueryHandlerMiddleware;
use League\Tactician\CommandBus as TacticianBus;
use League\Tactician\Handler\Locator\InMemoryLocator;
use League\Tactician\Plugins\LockingMiddleware;

$queryToHandlerMap = [];
        
$tacticianBus = new TacticianBus([
    new LockingMiddleware(),
    new QueryHandlerMiddleware(new InMemoryLocator($queryToHandlerMap)),
]);

$queryBus = new QueryBus($tacticianBus);

/** @var \Gears\CQRS\Query $query */
$result = $queryBus->handle($query);

Contributing

Found a bug or have a feature request? Please open a new issue. Have a look at existing issues before.

See file CONTRIBUTING.md

License

See file LICENSE included with the source code for a copy of the license terms.

About

IMPLEMENTATION - CQRS with League Tactician

Resources

Contributing

Stars

2 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages