netolabs/simple-event-dispatcher

Basic event dispatcher based on the PSR-14 standard

v0.1.0 2020-03-09 05:16 UTC

This package is auto-updated.

Last update: 2024-12-09 16:11:11 UTC


README

Basic event dispatcher based on the PSR-14 standard.

Install

Via Composer

$ composer require netolabs/simple-event-dispatcher

Requirements

PHP version 7.3 and up is required.

Usage

Adding a listener

$listenerProvider = new ListenerProvider();
$dispatcher = new EventDispatcher($listenerProvider);

$listenerProvider->addListener(MyEvent::class, function() {
    // ...
});

Emitting an event

$event = new MyEvent();

$dispatcher->dispatch($event);

License

The MIT License (MIT). Please see the License File for more information.