PHP Classes

Lazy PHP Event Handler: Register event handlers to be loaded dynamically

Recommend this page to a friend!
  Info   Documentation   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not yet rated by the usersTotal: 60 All time: 10,508 This week: 455Up
Version License PHP version Categories
event-module 1.0.0MIT/X Consortium ...5PHP 5, Language
Description 

Author

This package can register event handlers that are loaded dynamically.

It can register event handlers with code from separate configuration PHP script files.

When the events are triggered, the package can load the handler dynamically and call it.

The package can also cache the compiled event handler code in PHP scripts to be loaded faster next time the respective is triggered.

Innovation Award
PHP Programming Innovation award nominee
November 2021
Number 2
Many applications need to execute tasks that can take some time to complete.

One way to process the results of those tasks is to use event handlers that register callback functions that the handlers invoke after the tasks are complete.

This package allows developers to configure event handlers from configuration scripts that are loaded dynamically. This possibility makes it possible to separate the task executing from the task processing using different PHP source code files.

Manuel Lemos
Picture of Melanie Wehowski
  Performance   Level  
Innovation award
Innovation award
Nominee: 12x

 

Documentation

event-module

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);

  Files folder image Files (14)  
File Role Description
Files folder imageconfig (1 file)
Files folder imagesrc (2 directories)
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file config.xml Data Auxiliary data
Accessible without login Plain text file LICENSE Lic. License text
Accessible without login Plain text file README.md Doc. Documentation

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 100%
Total:60
This week:0
All time:10,508
This week:455Up