1. Go to this page and download the library: Download berlioz/event-manager library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
berlioz / event-manager example snippets
use Berlioz\EventManager\EventDispatcher;
$dispatcher = new EventDispatcher();
use Berlioz\EventManager\EventDispatcher;
$callback = function($event) {
// Do something
return $event;
};
/** @var EventDispatcher $dispatcher */
// A named event
$dispatcher->addEventListener('event.name', $callback);
// Your event object
$dispatcher->addEventListener(MyEvent::class, $callback);
/** @var EventDispatcher $dispatcher */
use Berlioz\EventManager\Event\CustomEvent;
use Berlioz\EventManager\EventDispatcher;
// A named event
$dispatcher->dispatch(new CustomEvent('event.name'));
// Your event object
$dispatcher->dispatch(new MyEvent());
use Berlioz\EventManager\Listener\ListenerInterface;
/** ... */
// Normal priority (0)
$dispatcher->addEventListener('event.name', $callback, ListenerInterface::PRIORITY_NORMAL);
// High priority (100)
$dispatcher->addEventListener('event.name', $callback, ListenerInterface::PRIORITY_HIGH);
// Low priority (-100)
$dispatcher->addEventListener('event.name', $callback, ListenerInterface::PRIORITY_LOW);
use Berlioz\EventManager\EventDispatcher;
$dispatcher = new EventDispatcher();
$dispatcher->addEventDispatcher(new MyCustomDispatcher());
use Berlioz\EventManager\EventDispatcher;
$dispatcher = new EventDispatcher();
$dispatcher->addListenerProvider(new MyListenerProvider());
use Berlioz\EventManager\EventDispatcher;
use Berlioz\EventManager\Provider\ListenerProvider;$myDefaultProvider = new ListenerProvider();
$dispatcher = new EventDispatcher(defaultProvider: $myDefaultProvider);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.