bauhaus / message-bus
Yet another message bus implementation
v0.0.0
2021-09-25 23:08 UTC
Requires
- php: ^8.0
- psr/container: ^2.0
Requires (Dev)
- phpunit/phpunit: ^9.5
This package is auto-updated.
Last update: 2024-10-17 07:22:27 UTC
README
Message Bus
Installing
$ composer require bauhaus/message-bus
Getting Started
<?php use Bauhaus\MessageBus; use Bauhaus\MessageBusSettings; class YourCommand {} class YourCommandHandler { public function __invoke(CommandA $command): void {} } class YourQuery {} class YourQueryResult {} class YourQueryHandler { public function __invoke(YourQuery $query): YourQueryResult { return new YourQueryResult(); } } $messageBus = MessageBus::build( MessageBusSettings::new() ->withPsrContainer(/* Pass here your favorite PSR container */) ->withHandlers( YourCommandAHandler::class, YourQueryHandler::class, ); ); $result = $messageBus->dispatch(new YourCommand()); is_null($result); // true $result = $messageBus->dispatch(new YourCommand()); $result instanceof YourQueryResult; // true
Contributing
Open an issue: https://github.com/bauhausphp/message-bus/issues Code: https://github.com/bauhausphp/contributor-tool