1. Go to this page and download the library: Download dhii/event-interface 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/ */
use Psr\EventDispatcher\EventDispatcherInterface;
use Dhii\Events\Event\EventInterface;
use Dhii\Events\Event\StoppableEventFactoryInterface;
use Dhii\Events\Listener\AddListenerCapableInterface;
/* @var $dispatcher EventDispatcherInterface */
/* @var $factory StoppableEventFactoryInterface */
/* @var $listenerMap AddListenerCapableInterface */
// First listener will change a value and stop propagation
$listenerMap->addListener('my_event', function (EventInterface $event) {
$params = $event->getParams();
$params['key'] = 'other_value';
$event->setParams($params);
$event->stopPropagation();
}, 1);
// Second listener is never run, therefore the value does not change again
$listenerMap->addListener('my_event', function (EventInterface $event) {
$params = $event->getParams();
$params['key'] = 'yet another value';
$event->setParams($params);
}, 2);
$event = $factory->make('my_event', ['key' => 'value']);
$dispatcher->dispatch($event);
echo $event->getParam('key'); // 'other_value'
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.