1. Go to this page and download the library: Download aesonus/events 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/ */
aesonus / events example snippets
$dispatcher = new Dispatcher();
class MyEvent extends Event { }
...
public function handle(EventInterface $event): void { }
}
$event = new MyEvent();
$event->attach(new MyListener());
$listeners = [new MyListener(),[new MyListener(), 2],new MyListener()];
//They all get a priority of 3, except for the the listener at index 1
$event->attach($listeners, 3);
$dispatcher->register($event);
$dispatcher->dispatch(MyEvent::class);
$event->dispatch();
try {
$event->dispatch(); // This will throw an exception from one of the listeners
} catch (ResumableException $ex) {
//do stuff to make all better
}
//Resume the dispatch
$event->dispatch();
...
$event->reset();
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.