Download the PHP package spiral-packages/event-bus without Composer
On this page you can find all versions of the php package spiral-packages/event-bus. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download spiral-packages/event-bus
More information about spiral-packages/event-bus
Files in spiral-packages/event-bus
Package event-bus
Short Description A simple observer pattern implementation based on symfony event handler, allowing you to subscribe and listen for various events that occur within your application.
License MIT
Homepage https://github.com/spiral-packages/event-bus
Informations about the package event-bus
A simple observer pattern implementation based on symfony event handler (PSR-14 compatible)
Subscribe and listen for various events that occur within your application.
Requirements
Make sure that your server is configured with following PHP version and extensions:
- PHP 8.0+
- Spiral framework 2.9+
Installation
You can install the package via composer:
After package install you need to register bootloader from the package.
or
Usage
At first need create config file app/config/event-bus.php
, where you can specify listeners.
You can also register listeners via Spiral\EventBus\ListenerRegistryInterface
Event example
Listener example
Make sure to use variable
$event
for event handler method. It's required.
Listener example with attributes
If you are using listeners with attributes 'discoverListeners' = true
, you don't need to register them, they will be
registered automatically.
Listener example that should be handled in a queue
If you want to push listener to a queue, you can add Spiral\EventBus\QueueableInterface
Event dispatching
Interceptors
The package provides convenient Bootloader to configure core
interceptors Spiral\EventBus\Bootloader\EventBusBootloader
automatically:
or via config app/config/event-bus.php
Testing
If you are using spiral/testing
package in your application, you can additionally
use trait Spiral\EventBus\Testing\InteractsWithEvents
in your tests cases.
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
- butschster
- All Contributors
License
The MIT License (MIT). Please see License File for more information.
All versions of event-bus with dependencies
symfony/event-dispatcher Version ^6.0
spiral/attributes Version ^2.8 || ^3.0
spiral/boot Version ^3.0
spiral/config Version ^3.0
spiral/core Version ^3.0
spiral/hmvc Version ^3.0
spiral/tokenizer Version ^3.0
spiral/queue Version ^3.0