PHPackages                             malocher/zf2-cqrs-module - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Framework](/categories/framework)
4. /
5. malocher/zf2-cqrs-module

ActiveLibrary[Framework](/categories/framework)

malocher/zf2-cqrs-module
========================

PHP CQRS + Service Bus integration for Zend Framework 2

v1.0(12y ago)7128BSD-3-ClausePHPPHP &gt;=5.4.0

Since Dec 10Pushed 12y ago5 watchersCompare

[ Source](https://github.com/malocher/zf2-cqrs-module)[ Packagist](https://packagist.org/packages/malocher/zf2-cqrs-module)[ Docs](https://github.com/malocher/zf2-cqrs-module)[ RSS](/packages/malocher-zf2-cqrs-module/feed)WikiDiscussions master Synced 3w ago

READMEChangelog (1)Dependencies (3)Versions (2)Used By (0)

MalocherCqrsModule
==================

[](#malochercqrsmodule)

Zend Framework 2 Module that integrates the [Malocher CQRS + Service Bus](https://github.com/malocher/cqrs-esb)

[![Build Status](https://camo.githubusercontent.com/1e1781064a86a834241303ae0b4420a2cd435e89ca7f4c3c91969db9cffa7e38/68747470733a2f2f7472617669732d63692e6f72672f6d616c6f636865722f7a66322d637172732d6d6f64756c652e706e673f6272616e63683d6d6173746572)](https://travis-ci.org/malocher/zf2-cqrs-module)

Installation
------------

[](#installation)

Installation of MalocherCqrsModule uses composer. For composer documentation, please refer to [getcomposer.org](http://getcomposer.org/). Add following requirement to your composer.json

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

Then add `MalocherCqrsModule` to your `config/application.config.php``

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

Setup
-----

[](#setup)

Setup the CQRS System using your module or application configuration. Put all CQRS options under the key cqrs.

```
  '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.

\##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:

```
