malocher/zf2-cqrs-module
Composer 安装命令:
composer require malocher/zf2-cqrs-module
包简介
PHP CQRS + Service Bus integration for Zend Framework 2
关键字:
README 文档
README
Zend Framework 2 Module that integrates the Malocher CQRS + Service Bus
Installation
Installation of MalocherCqrsModule uses composer. For composer documentation, please refer to 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 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:
<?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
统计信息
- 总下载量: 128
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 7
- 点击次数: 0
- 依赖项目数: 5
- 推荐数: 1
其他信息
- 授权协议: BSD-3-Clause
- 更新时间: 2013-12-04