PHP code example of aztech / event-dispatcher
1. Go to this page and download the library: Download aztech/event-dispatcher 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/ */
aztech / event-dispatcher example snippets
class MyEvent implements \Aztech\Events\Event
{
function getCategory() {
return 'my.event';
}
function getId() {
return 1;
}
}
$dispatcher = new \Aztech\Events\EventDispatcher();
$subscriber = new \Aztech\Events\Callback(function (\Aztech\Events\Event $event) {
echo 'I just received an event : ' . $event->getCategory() . PHP_EOL;
});
$dispatcher->addListener('my.#', $subscriber);
$dispatcher->dispatch(new MyEvent());