hschulz/php-event-dispatcher

An implementation of the PSR-14 Event Dispatcher Interface.

0.1.7 2024-04-20 19:14 UTC

This package is auto-updated.

Last update: 2024-10-20 20:34:27 UTC


README

An implementation of the PSR-14 Event Dispatcher Interface.

Installation

composer require hschulz/php-event-dispatcher

Usage

<?php

declare(strict_types=1);

require 'vendor/autoload.php';

use Hschulz\EventDispatcher\EventDispatcher;

$dispatcher = new EventDispatcher();

$dispatcher->addListener('event.name', function ($event) {
    echo 'Event triggered: ' . $event->getName() . PHP_EOL;
});

$dispatcher->dispatch('event.name');

License

This project is released under the MIT license.