nepada / message-bus-nette
Integration of nepada/message-bus into Nette Framework.
Installs: 1 531
Dependents: 0
Suggesters: 0
Security: 0
Stars: 3
Watchers: 3
Forks: 0
Open Issues: 0
Requires
- php: >=8.2.0 <8.5
- nepada/message-bus: ^2.2@dev || ^3.0@dev
- nette/di: ^3.0.9@dev
- nette/schema: ^1.2.2@dev
- nette/utils: ^3.2.5@dev || ^4.0@dev
- psr/container: ^1.1 || ^2.0
- symfony/messenger: ^5.0@dev || ^6.0@dev || ^7.0@dev
Requires (Dev)
- composer-runtime-api: ^2.0
- composer/semver: 3.4.3
- doctrine/dbal: >=2.13.3
- doctrine/orm: >=2.13
- nepada/coding-standard: 7.14.0
- nepada/message-bus-doctrine: ^2.1@dev
- nepada/phpstan-nette-tester: 1.2.1
- nette/bootstrap: >=3.1@dev
- nette/neon: >=3.3.4@dev
- nette/robot-loader: >=3.3.1@dev
- nette/tester: 2.5.4
- php-parallel-lint/php-parallel-lint: 1.4.0
- phpstan/phpstan: 1.12.5
- phpstan/phpstan-nette: 1.3.8
- phpstan/phpstan-strict-rules: 1.6.1
- shipmonk/phpstan-rules: 3.2.0
- spaze/phpstan-disallowed-calls: 3.4.0
- symfony/cache: ^6.3.12 || ^6.4.3 || ^7.0.3 || >=7.1
- symfony/cache-contracts: >=3.4.2
README
Installation
Via Composer:
$ composer require nepada/message-bus-nette
Register the extension in config.neon
:
extensions: messageBus: Nepada\MessageBusNette\DI\MessageBusExtension
Usage
See nepada/message-bus for the documentation of the core library.
Logging
The extension tries to autowire PSR compatible logger into logging middleware. If this doesn't work for you, specify the logger service in configuration explicitly:
messageBus: logger: @myLoggerService
Nested command handling
Nested command handling is not allowed by default, this can be changed in configuration:
messageBus: allowNestedCommandHandling: true
Doctrine
Doctrine ORM specific features for message bus are provided by nepada/message-bus-doctrine package. Follow the link for more detailed documentation. Once you install the package, it gets detected by DI extension and all necessary services are set up.
With Doctrine integration:
- all commands are handled in a transaction and all changes are automatically flushed and commited after the handler successfully finishes, or rolled back on error,
- database transactions started outside of command bus are forbidden,
- entity manager is (optionally) cleared before and after the handling of every command.
Change or completely disable the default entity manager clearing logic:
messageBus: clearEntityManager onStart: false onSuccess: false onError: false
You can record your domain events inside entities implementing Nepada\Bridges\MessageBusDoctrine\Events\ContainsRecordedEvents
and they will be automatically collected and dispatched on flush.
Tip: use SearchExtension to auto-register command handlers and event subscribers
search: messageBusHandlers: in: %appDir% implements: - Nepada\MessageBus\Commands\CommandHandler - Nepada\MessageBus\Events\EventSubscriber