CQRSModule integrates CQRS library with Zend Framework 2 quickly and easily.
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
return [
'cqrs' => [
'commandHandlerLocator' => [
'cqrs_default' => [
'handlers' => [
'UserService' => [
'ChangeUserName'
]
]
]
],
'eventHandlerLocator' => [
'cqrs_default' => [
'services' => [
'EchoEventListener' => [
'UserNameChanged'
]
]
]
]
]
];
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
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');