pauci / cqrs-module
提供CQRS库功能的Zend Framework 2模块
v0.3.2
2018-08-30 13:03 UTC
Requires
- php: ^5.6 || ^7.0
- pauci/cqrs: ^0.2.5
- zendframework/zend-mvc: ^2.7.10 || ^3.0.4
- zendframework/zend-servicemanager: ^2.7.8 || ^3.2.0
- zendframework/zend-stdlib: ^2.7.7 || ^3.1.0
Requires (Dev)
README
CQRSModule快速简单地集成了CQRS库与Zend Framework 2。
安装
此模块的安装使用composer。有关composer文档,请参阅getcomposer.org。
通过命令安装模块
php composer.phar require pauci/cqrs-module
# (When asked for a version, type `dev-master`)
然后,将CQRSModule
添加到您的config/application.config.php
设置
return [ 'cqrs' => [ 'commandHandlerLocator' => [ 'cqrs_default' => [ 'handlers' => [ 'UserService' => [ 'ChangeUserName' ] ] ] ], 'eventHandlerLocator' => [ 'cqrs_default' => [ 'services' => [ 'EchoEventListener' => [ 'UserNameChanged' ] ] ] ] ] ];
已注册的服务名称
cqrs.command_bus.cqrs_default
: 一个CQRS\CommandHandling\CommandBusInterface
实例cqrs.command_handler_locator.cqrs_default
: 一个CQRS\CommandHandling\Locator\CommandHandlerLocatorInterface
实例cqrs.transaction_manager.cqrs_default
: 一个CQRS\CommandHandling\TransactionManager\TransactionManagerInterface
实例cqrs.event_publisher.cqrs_default
: 一个CQRS\EventHandling\Publisher\EventPublisherInterface
实例cqrs.event_bus.cqrs_default
: 一个CQRS\EventHandling\EventBusInterface
实例cqrs.event_handler_locator.cqrs_default
: 一个CQRS\EventHandling\Locator\EventHandlerLocatorInterface
实例cqrs.event_store.cqrs_default
: 一个CQRS\EventStore\EventStoreInterface
实例cqrs.serializer.reflection
: 一个CQRS\Serializer\ReflectionSerializer
实例
服务定位器
要访问实体管理器,请使用主服务定位器
// for example, in a controller: $commandBus = $this->getServiceLocator()->get('cqrs.command_bus.cqrs_default'); $eventHandlerLocator = $this->getServiceLocator()->get('cqrs.event_handler_locator.cqrs_default');