helthe/cqrs

Helthe CQRS Component

dev-master / 1.0.x-dev 2014-09-16 22:17 UTC

This package is auto-updated.

Last update: 2024-03-29 02:39:23 UTC


README

Helthe CQRS is a small library implementing command-query separation. It's based on the refactored version of LiteCQRS and the work of Mark Nijhof for his CQRS book.

Currently, the library only implements command handling using a command bus for communication.

Installation

Using Composer

Manually

Add the following in your composer.json:

{
    "require": {
        // ...
        "helthe/cqrs": "dev-master"
    }
}

Using the command line

$ composer require 'helthe/cqrs=dev-master'

Usage

The component contains mainly helper interfaces for implementing CQRS. Some basic implementations are also included.

use Helthe\Component\CQRS\Bus\SequentialCommandBus;
use Helthe\Component\CQRS\Command\CommandInterface;
use Helthe\Component\CQRS\CommandHandler\CommandHandlerInterface;
use Helthe\Component\CQRS\CommandHandler\MemoryCommandHandlerLocator;

/* @var CommandInterface */
$command = new Command()
/* @var CommandHandlerInterface */
$handler = new CommandHandler()

$locator = new MemoryCommandHandlerLocator();
$locator->register(get_class($command), $handler);

$bus = new SequentialCommandBus($locator);

$bus->dispatch($command);

Bugs

For bugs or feature requests, please create an issue.