A basic PSR-14 implementation using a priority queue

v1.1 2022-11-13 19:35 UTC

This package is auto-updated.

Last update: 2024-02-13 22:20:50 UTC


Tests Coverage Status

This package offers a simple event dispatcher using an event priority queue, following the PSR-14 Event Dispatcher recommendation.


Via Composer

composer require piko/event-dispatcher

Then ensure that the following file is included in your PHP project:

require 'vendor/autoload.php'; // The Composer autoloader


use Piko\Event;
use Piko\ListenerProvider;
use Piko\EventDispatcher;

class MyEvent extends \Piko\Event
    public $value;

$provider = new ListenerProvider();
$dispatcher = new EventDispatcher($provider);
$event = new MyEvent();

$provider->addListenerForEvent(MyEvent::class, function(MyEvent $event) {
    $event->value .= 'World !';

$provider->addListenerForEvent(MyEvent::class, function(MyEvent $event) {
    $event->value .= 'Hello ';
}, 10); // Set the priority to 10


echo $event->value; // Hello World!