pauci / cqrs-module
Zend Framework 2 Module that provides functionality for CQRS library
Installs: 1 617
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 3
Open Issues: 0
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 integrates CQRS library with Zend Framework 2 quickly and easily.
Installation
Installation of this module uses composer. For composer documentation, please refer to getcomposer.org.
Install the module via command:
php composer.phar require pauci/cqrs-module
# (When asked for a version, type `dev-master`)
Then add CQRSModule
to your config/application.config.php
Setup
return [ 'cqrs' => [ 'commandHandlerLocator' => [ 'cqrs_default' => [ 'handlers' => [ 'UserService' => [ 'ChangeUserName' ] ] ] ], 'eventHandlerLocator' => [ 'cqrs_default' => [ 'services' => [ 'EchoEventListener' => [ 'UserNameChanged' ] ] ] ] ] ];
Registered Service names
cqrs.command_bus.cqrs_default
: aCQRS\CommandHandling\CommandBusInterface
instancecqrs.command_handler_locator.cqrs_default
: aCQRS\CommandHandling\Locator\CommandHandlerLocatorInterface
instancecqrs.transaction_manager.cqrs_default
: aCQRS\CommandHandling\TransactionManager\TransactionManagerInterface
instancecqrs.event_publisher.cqrs_default
: theCQRS\EventHandling\Publisher\EventPublisherInterface
instancecqrs.event_bus.cqrs_default
: theCQRS\EventHandling\EventBusInterface
instancecqrs.event_handler_locator.cqrs_default
: theCQRS\EventHandling\Locator\EventHandlerLocatorInterface
instancecqrs.event_store.cqrs_default
: theCQRS\EventStore\EventStoreInterface
instancecqrs.serializer.reflection
: theCQRS\Serializer\ReflectionSerializer
instance
Service Locator
To access the entity manager, use the main service locator:
// for example, in a controller: $commandBus = $this->getServiceLocator()->get('cqrs.command_bus.cqrs_default'); $eventHandlerLocator = $this->getServiceLocator()->get('cqrs.event_handler_locator.cqrs_default');