Releases: WyriHaximus/php-broadcast
1.0.0
Installation
To install via Composer, use the command below, it will automatically detect the latest version and bind it with ^.
composer require wyrihaximus/broadcast
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.
{
  "extra": {
    "wyrihaximus": {
      "broadcast": {
        "has-listeners": true
      }
    }
  }
}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:
use WyriHaximus\Broadcast\ContainerListenerProvider;
use WyriHaximus\Broadcast\Dispatcher;
use WyriHaximus\Broadcast\Dummy�vent;
$event = new Event();
(new Dispatcher(new ContainerListenerProvider($container), $logger))->dispatch($event)Listener
The following listener is from one of my apps and listeners both on intialize and shutdown events. The logic has been
taken out, but logging is left intact to demonstracte a simple listener example.
<?php
declare(strict_types=1);
namespace WyriHaximus\Apps\WyriHaximusNet\GitHub\Ingest;
use Mammatus\LifeCycleEvents\Initialize;
use Mammatus\LifeCycleEvents\Shutdown;
use Psr\Log\LoggerInterface;
use WyriHaximus\Broadcast\Contracts\Listener;
final class Consumer implements Listener
{
    private LoggerInterface $logger;
    public function __construct(ConsumerContract $consumer, Producer $producer, LoggerInterface $logger)
    {
        $this->logger   = $logger;
    }
    public function start(Initialize $event): void
    {
        $this->logger->debug('Starting to consume ingested GitHub WebHook events');
    }
    public function stop(Shutdown $event): void
    {
        $this->logger->debug('Stopping to consume ingested GitHub WebHook events');
    }
}1.0.0
- Total issues resolved: 0
 - Total pull requests resolved: 20
 - Total contributors: 2
 
Documentation 📚,MarkDown 📝
- 48: Add listener example thanks to @WyriHaximus
 - 36: Add documentation thanks to @WyriHaximus
 
CI 🚧,Configuration ⚙,Dependencies 📦,JSON 👨💼,PHP 🐘,YAML 🍄
- 47: Add PHP 8 support thanks to @WyriHaximus
 
Dependencies 📦,PHP 🐘
- 46: Bump wyrihaximus/test-utilities from 3.3.1 to 3.3.2 thanks to @dependabot[bot]
 - 45: Bump roave/better-reflection from 4.12.0 to 4.12.1 thanks to @dependabot[bot]
 - 44: Bump illuminate/collections from 8.11.2 to 8.19.0 thanks to @dependabot[bot]
 - 43: Bump illuminate/collections from 8.11.2 to 8.18.1 thanks to @dependabot[bot]
 - 41: Bump wyrihaximus/constants from 1.5.0 to 1.6.0 thanks to @dependabot[bot]
 - 40: Bump thecodingmachine/safe from 1.3.2 to 1.3.3 thanks to @dependabot[bot]
 - 39: Bump roave/better-reflection from 4.11.0 to 4.12.0 thanks to @dependabot[bot]
 - 38: Bump pimple/pimple from 3.3.0 to 3.3.1 thanks to @dependabot[bot]
 - 34: Bump roave/better-reflection from 4.9.0 to 4.10.0 thanks to @dependabot[bot]
 - 33: Bump thecodingmachine/safe from 1.2.0 to 1.2.1 thanks to @dependabot[bot]
 - 32: Bump composer/composer from 1.10.10 to 1.10.13 thanks to @dependabot[bot]
 - 30: Bump wyrihaximus/test-utilities from 2.6.0 to 2.7.0 thanks to @dependabot[bot]
 - 29: Bump thecodingmachine/safe from 1.1.3 to 1.2.0 thanks to @dependabot[bot]