2017-25 © Pedro Peláez
 

library zf2-cqrs-module

PHP CQRS + Service Bus integration for Zend Framework 2

image

malocher/zf2-cqrs-module

PHP CQRS + Service Bus integration for Zend Framework 2

  • Saturday, December 21, 2013
  • by Malocher
  • Repository
  • 5 Watchers
  • 8 Stars
  • 107 Installations
  • PHP
  • 5 Dependents
  • 1 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 1 % Grown

The README.md

MalocherCqrsModule

Zend Framework 2 Module that integrates the Malocher CQRS + Service Bus, (*1)

Build Status, (*2)

Installation

Installation of MalocherCqrsModule uses composer. For composer documentation, please refer to getcomposer.org. Add following requirement to your composer.json, (*3)

"malocher/zf2-cqrs-module" : "1.*"

Then add MalocherCqrsModule to your `config/application.config.php``, (*4)

Installation without composer is not officially supported, and requires you to install and autoload the dependencies specified in the composer.json., (*5)

Setup

Setup the CQRS System using your module or application configuration. Put all CQRS options under the key cqrs., (*6)

  'cqrs' => array(
        'adapters' => array(
            'Malocher\Cqrs\Adapter\ArrayMapAdapter' => array(
                'buses' => array(
                    'My\Bus\DomainBus' => array(
                        'My\Command\AddEntityCommand' => array(
                            'alias'  => 'my_add_entity_command_handler',
                            'method' => 'addEntity' 
                        ),
                    ),
                ),
            ),
        ),
    ),
    'service_manager' => array(
        'invokables' => array(
            'my_add_entity_command_handler' => 'My\Repository\EntityRepository',
        ),
    ),

The ZF2 ServiceManager acts as Handler- and EventListenerLoader. That means, you can use your ServiceManager aliases to pipe your commands, queries and events to your repositories, services and whatever you use in your application., (*7)

Usage

You can request the Malocher CQRS Gate from the ServiceManager. The hole setup of the CQRS and Service Bus System is done in the background. Here is a simple example that invokes the AddEntityCommand on the DomainBus from within a controller:, (*8)

<?php
namespace My\Controller;

use Zend\Mvc\Controller\AbstractActionController;
use My\Command\AddEntityCommand;
use My\Bus\DomainBus;

class MyController extends AbstractActionController {

  public function addEntityAction() {

    $entityName = $this->getEvent()->getRouteMatch()->getParam('entityname');

    $addEntityCommand = new AddEntityCommand();

    $addEntityCommand->setName($entityName);

    $this->getServiceLocator()
      ->get('malocher.cqrs.gate')
      ->getBus(DomainBus::NAME)
      ->invokeCommand($addEntityCommand);
  }
}

Sample Application

You can find a sample application with annotated sourcecode on malocher/zf2-cqrs-sample, (*9)

The Versions

21/12 2013

dev-master

9999999-dev https://github.com/malocher/zf2-cqrs-module

PHP CQRS + Service Bus integration for Zend Framework 2

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

framework zf2 cqrs esb

10/12 2013

v1.0

1.0.0.0 https://github.com/malocher/zf2-cqrs-module

PHP CQRS + Service Bus integration for Zend Framework 2

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

framework zf2 cqrs esb