php-ddd / php-ddd-bundle
Library to manage event
Installs: 4 324
Dependents: 0
Suggesters: 0
Security: 0
Stars: 4
Watchers: 4
Forks: 0
Open Issues: 0
Requires
- php: >=5.3.3
- php-ddd/command: ~1.0
- php-ddd/domain-event: ~1.0
- symfony/console: ~2.3
- symfony/framework-bundle: ~2.3
Requires (Dev)
- fabpot/php-cs-fixer: dev-master
- phpunit/phpunit: 4.0.*
This package is not auto-updated.
Last update: 2024-11-09 17:45:19 UTC
README
PhpDDDBundle provides some tools to integrate php-ddd/domain-event and php-ddd/command inside your Symfony application.
Features
- Services for SequentialCommandBus and CommandHandlerLocator
- Services for EventBus and EventListenerLocator
- A service tag to link Command with CommandHandler easily
- A service tag to link Event with EventListener easily
- A
php-ddd:command-bus:debug
Symfony command to list every Command/CommandHandler for a given CommandBus - A
php-ddd:event-bus:debug
Symfony command to list every Event/EventListener attached to a given EventBus
Usage
Link a CommandHandler to a Command using tags
The easiest way to link a CommandHandler to a Command is by using service tag php_ddd.command_handler
on the CommandHandler:
# services.yml services: my.command_handler.foo: class: My/CommandHandler/FooCommandHandler tags: - { name: php_ddd.command_handler, command: My/Command/Foo }
The CommandHandler will be automatically registered in the phpddd_command.handler_locator
service which correspond to a CommandHandlerLocator.
This CommandHandlerLocator is then passed to the phpddd_command.bus
service which correspond to a SequentialCommandBus by default.
Add an EventListener listening to an Event using tags
It works the same way as for CommandHandler and Command:
# services.yml services: my.listener.bar: class: My/EventListener/BarEventListener tags: - { name: php_ddd.event_listener, event: Other/Event/Bar }
The EventListener will be automatically registered in the phpddd_event.listener_locator
service which correspond to an EventListenerLocator.
This EventListener is then passed to the phpddd_event.bus
service which correspond to an EventBus by default.