Download the PHP package wyrihaximus/broadcast without Composer
On this page you can find all versions of the php package wyrihaximus/broadcast. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download wyrihaximus/broadcast
More information about wyrihaximus/broadcast
Files in wyrihaximus/broadcast
Package broadcast
Short Description ✨ Statically on composer install/update compiled (async) event dispatcher
License MIT
Informations about the package broadcast
Broadcast
✨ Statically on composer install/update compiled event dispatcher
Installation
To install via Composer, use the command below, it will automatically detect the latest version and bind it with ^
.
Usage
Any package setting the following in their composer.json
will have its autoloading directories and files scanned
for any classes that implements WyriHaximus\Broadcast\Contracts\Listener
. Each public method with a concrete object
type hint on classes implementing WyriHaximus\Broadcast\Contracts\Listener
will be registered as an event listener
for that object in the type hint.
To use those automatically picked up event listeners, use the WyriHaximus\Broadcast\ContainerListenerProvider
, which
needs a PSR-11
container to work.
The following example uses the dummy event and listener coming with this package:
Listener
The following listener is from one of my apps and listeners both on initialize and shutdown events. The logic has been taken out, but logging is left intact to demonstrate a simple listener example.
Async & Await
Besides synchronous PHP event dispatching this package also supports async & await through
ReactPHP
's async package.
To mark a class's listeners to run inside a fiber and have the dispatcher wait for each one to complete before
continuing, use the WyriHaximus\Broadcast\Contracts\AsyncListener
marker interface instead of Listener
.
License
The MIT License (MIT)
Copyright (c) 2023 Cees-Jan Kiewiet
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
All versions of broadcast with dependencies
ext-json Version ^8.2
composer-plugin-api Version ^2
psr/container Version ^1 || ^2
psr/event-dispatcher Version ^1
psr/log Version ^1.1 || ^2 || ^3
react/async Version ^4.3
react/promise Version ^3.2
roave/better-reflection Version ^6.26
wyrihaximus/broadcast-contracts Version ^1.3
wyrihaximus/generative-composer-plugin-tooling Version ^1.0.1