1. Go to this page and download the library: Download smoren/event-router 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/ */
smoren / event-router example snippets
use Smoren\EventRouter\Components\EventRouter;
use Smoren\EventRouter\Interfaces\EventInterface;
use Smoren\EventRouter\Events\Event;
use Smoren\EventRouter\Structs\EventConfig;
use Smoren\EventRouter\Loggers\ArrayLogger;
$router = new EventRouter(10, new ArrayLogger());
$router
->on(new EventConfig('origin1'), function(EventInterface $event) {
return null;
})
->on(new EventConfig('origin1', 'recursive_single'), function(EventInterface $event) {
return new Event('origin2', 'test');
})
->on(new EventConfig('origin1', 'recursive_multiple'), function(EventInterface $event) {
return [
new Event('origin1', 'recursive_single'),
new Event('origin2', 'test'),
];
})
->on(new EventConfig('origin2'), function(EventInterface $event) {
return null;
});
$router->send(new Event('origin1', 'first'));
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.