frdl/event-module

Register EventHandlers to be lazy loaded.

Installs: 177

Dependents: 2

Suggesters: 0

Security: 0

Stars: 0

Watchers: 1

Forks: 0

Open Issues: 0

Type:frdl-module

v0.0.15 2020-06-19 00:13 UTC

This package is auto-updated.

Last update: 2020-09-19 00:53:18 UTC


README

Register EventHandlers in PHP to be lazy loaded.

Usage

Configuration

Set the directory to save the events in.

$my_directory =  __DIR__.\DIRECTORY_SEPARATOR.'compiled-events';
 \Webfan\App\EventModule::setBaseDir($my_directory);

Register Events

Register the events by your configuration/build script/process.

\Webfan\App\EventModule::register('test', 'testing', static function($eventName, $emitter, \webfan\hps\Event $Event){
       print_r($Event->getArgument("testParam"));
});

Call Events

Dispatch the events later in a different script/process.

$event = new \webfan\hps\Event('testing');
$event->setArgument('testParam', 'testValue'); 
\Webfan\App\EventModule::action('test')->emit('testing', $event);