andy-thorne / domain-events-bundle
Domain events for Doctrine ODM and ORM
Installs: 532
Dependents: 0
Suggesters: 1
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
Type:symfony-bundle
Requires
- php: ^8.0
- symfony/framework-bundle: ^5.4|^6.0
- symfony/messenger: ^5.4|^6.0
- symfony/uid: ^5.4|^6.0
- symfony/yaml: ^5.4|^6.0
Requires (Dev)
- ext-mongo: *
- ext-mongodb: *
- alcaeus/mongo-php-adapter: ^1.2
- dama/doctrine-test-bundle: ^6.3
- doctrine/doctrine-bundle: ^2.0
- doctrine/mongodb-odm-bundle: ^4.0
- doctrine/orm: ^2.0
- escapestudios/symfony2-coding-standard: ^3.11
- friendsofphp/php-cs-fixer: ^3.0
- mongodb/mongodb: ^1.8
- phpspec/prophecy-phpunit: ^2.0
- phpunit/phpunit: ^9.1
- squizlabs/php_codesniffer: ^3.5
Suggests
- ext-mongo: For use with Doctrine ODM
- ext-mongodb: For use with Doctrine ODM
- alcaeus/mongo-php-adapter: For use with Doctrine ODM
- doctrine/mongodb-odm-bundle: For use with Doctrine ODM
- doctrine/orm-pack: For use with Doctrine ORM
- mongodb/mongodb: For use with Doctrine ODM
This package is auto-updated.
Last update: 2024-10-11 18:20:09 UTC
README
This bundle adds Domain Event dispatching on doctrine events via a MessageBus.
Installation
composer require andy-thorne/domain-events-bundle
Configuration
# Defaults domain_events: orm: true odm: false bus: domain_event.bus transport: async_domain_events configure_routing: true # Auto-configures messenger routing for DomainEventInterfaces to route to the configured transport framework: messenger: transports: async_domain_events: "%env(ASYNC_MESSENGER_TRANSPORT_DSN)%"
The bundle will also configure these messenger settings based on your domain_events
config. If you already have buses
configured, you will need to specify a framework.messenger.default_bus
.
# The bundle also configures your framework: messenger: # Set up a bus that will allows no handlers buses: <domain_events.bus>: default_middleware: allow_no_handlers # Route all domain events to the domain event transport if configure_routing is true (default) routing: 'AndyThorne\Components\DomainEventsBundle\Events\DomainEventInterface': <domain_events.transport>
Message Bus
Domain Events uses the app's MessageBus to transport domain events. The default Messenger Component is configured to be synchronous and requires at least one handler to be defined for each Message. For Domain Events to work, we need to configure an asynchronous MessageBus and allow it to have no handlers:
Why Asynchronous?
Domain Events are dispatched within a doctrine postFlush lifecycle event