1. Go to this page and download the library: Download krak/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/ */
interface EventEmitter {
public function on($event, $listener);
public function once($event, $listener);
public function removeListener($event, $listener);
public function removeAllListeners($event = null);
public function listeners($event);
public function emit($event, ...$arguments);
}
use Krak\EventEmitter\EventListener;
class AcmeListener implements EventListener
{
public function handle($param) {
}
}
$emitter->on('event', new AcmeListener());
use Krak\EventEmitter;
// this creates an emitter that will support container services as listeners
$invoke = new Krak\Invoke\ContainerInvoke(EventEmitter\emitterInvoke(), $container);
$emitter = Krak\EventEmitter\emitter($invoke);
$emitter->on('event', 'service_id');
$emitter->emit('event', 1);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.