1. Go to this page and download the library: Download ride/lib-event 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/ */
ride / lib-event example snippets
use ride\library\event\loader\io\EventListenerIO;
use ride\library\event\loader\GenericEventLoader;
use ride\library\event\GenericEventManager;
use ride\library\event\Event;
$eventManager = new GenericEventManager();
// add some event listeners
$eventManager->addEventListener('event', 'callback'); // provide a name of the event and a callback
$eventManager->addEventListener('event', array('MyClass', 'callback'), 10); // added a weight to influence order
$eventManager->addEventListener('test', 'onEvent');
// trigger an event
$eventManager->triggerEvent('test');
$eventManager->triggerEvent('test', array('var' => 'value'));
// event listener callback
function onEvent(Event $event) {
echo $event->getName();
echo $event->getArgument('var');
$event->setPreventDefault(); // stop the listener cascade after this listener
}
// you can lazy load the events through an EventLoader
class YourEventListenerIO implements EventListenerIO {
public function readEventListeners() {
return array(
'event' => array(
new EventListener('event', 'callback'),
);
);
}
}
$eventListenerIO = new YourEventListenerIO();
$eventLoader = new GenericEventLoader($eventListenerIO);
// all the events will be read at the first trigger, but only initialized when
// the actual event is triggered
$eventManager->setEventLoader($eventLoader);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.