blacksmith-project / event-bus
This package is abandoned and no longer maintained.
No replacement package was suggested.
A PHP Library
v0.2.1
2019-01-12 15:34 UTC
Requires
Requires (Dev)
- escapestudios/symfony2-coding-standard: ^3.4
- mnapoli/pretty: ^1.0
- phpstan/phpstan: ^0.10
- phpunit/phpunit: ^7.3
- squizlabs/php_codesniffer: ^3.3
This package is auto-updated.
Last update: 2020-02-12 17:59:59 UTC
README
Why ?
In order to improve my skills, I'm doing my own implementation of an EventBus.
Installation
composer require blacksmith-project/event-bus
How to use it ?
- Your events need to implement the empty interface
\BSP\Event
- Your listeners need to implement the interface
\BSP\EventListener
- Extends
\BSP\EventBus
and add in your constructor the listeners.
Please note that there may be multiple listeners to a single event.
You can look for example in the tests/Mock folder.
Now, you only need to inject your EventBus and send Events.
Example:
public function __construct(EventBus $eventBus) { $this->eventBus = $eventBus } public function handle(DoSomething $doSomething): void { // do business logic $event = new SomethingDone(); $this->eventBus->send($event); }