1. Go to this page and download the library: Download devco/event-emitter 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/ */
devco / event-emitter example snippets
// if using directly
er just use the autoload
r;
public function register($infos) {
// do something
// fire the event
$this->emit('register', $infos);
}
}
// allows you to check if a class uses the event emitter through
// $class instanceof \Nekoo\EventEmitterInterface
class AnotherItem implements \Nekoo\EventEmitterInterface {
use \Nekoo\EventEmitter;
}
// create an instance of our object
$i = new Item();
// register an observer for the register event
$i->on('register', function($infos) {
echo "Item registered!\n";
var_dump($infos);
});
// call the method
$i->register(array('key' => 'value'));