PHP Classes

Event router: Register event handlers and dispatch events

Recommend this page to a friend!
  Info   View files View files (27)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not yet rated by the usersTotal: 43 This week: 1All time: 10,807 This week: 65Up
Version License PHP version Categories
event-router-php 1.0MIT/X Consortium ...7.4Algorithms, Libraries, Language, PHP 7
Description 

Author

This package can register event handlers and dispatch events.

It provides a class that can register event handler callback functions associated with a given event name.

The package can also dispatch an event with a given name by calling all callback functions registered to handle events with that name.

Picture of Smoren  Freelight
  Performance   Level  
Name: Smoren Freelight <contact>
Classes: 38 packages by
Country: Russian Federation Russian Federation
Age: 34
All time rank: 284078 in Russian Federation Russian Federation
Week rank: 44 Up4 in Russian Federation Russian Federation Up
Innovation award
Innovation award
Nominee: 16x

Details

event-router

Packagist PHP Version Support Scrutinizer Code Quality Code Coverage Build and test License: MIT <!-- Coverage Status -->

Router for flexible configuring of event handling behaviors.

How to install to your project

composer require smoren/event-router

Unit testing

composer install
composer test-init
composer test

Usage

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

  Files folder image Files  
File Role Description
Files folder image.github (1 directory)
Files folder imagesrc (7 directories)
Files folder imagetests (3 files, 2 directories)
Accessible without login Plain text file codeception.yml Data Auxiliary data
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file LICENSE Lic. License text
Accessible without login Plain text file README.md Doc. Documentation

  Files folder image Files  /  .github  
File Role Description
Files folder imageworkflows (1 file)

  Files folder image Files  /  .github  /  workflows  
File Role Description
  Accessible without login Plain text file test_master.yml Data Auxiliary data

  Files folder image Files  /  src  
File Role Description
Files folder imageComponents (2 files)
Files folder imageEvents (2 files)
Files folder imageExceptions (1 file)
Files folder imageInterfaces (6 files)
Files folder imageLinks (1 file)
Files folder imageLoggers (2 files)
Files folder imageStructs (2 files)

  Files folder image Files  /  src  /  Components  
File Role Description
  Plain text file EventRouter.php Class Class source
  Plain text file EventRouterMap.php Class Class source

  Files folder image Files  /  src  /  Events  
File Role Description
  Plain text file Event.php Class Class source
  Plain text file LinkedEvent.php Class Class source

  Files folder image Files  /  src  /  Exceptions  
File Role Description
  Plain text file EventRouterException.php Class Class source

  Files folder image Files  /  src  /  Interfaces  
File Role Description
  Plain text file EventConfigInterface.php Class Class source
  Plain text file EventInterface.php Class Class source
  Plain text file EventLinkInterface.php Class Class source
  Plain text file EventRouterInterface.php Class Class source
  Plain text file EventRouteRuleInterface.php Class Class source
  Plain text file LoggerInterface.php Class Class source

  Files folder image Files  /  src  /  Loggers  
File Role Description
  Plain text file ArrayLogger.php Class Class source
  Plain text file FakeLogger.php Class Class source

  Files folder image Files  /  src  /  Structs  
File Role Description
  Plain text file EventConfig.php Class Class source
  Plain text file EventRouteRule.php Class Class source

  Files folder image Files  /  tests  
File Role Description
Files folder imageunit (2 files)
Files folder image_support (1 file)
  Accessible without login Plain text file coding_standard.xml Data Auxiliary data
  Accessible without login Plain text file unit.suite.yml Data Auxiliary data
  Accessible without login Plain text file _bootstrap.php Aux. Auxiliary script

  Files folder image Files  /  tests  /  unit  
File Role Description
  Plain text file EventRouterTest.php Class Class source
  Plain text file EventTest.php Class Class source

  Files folder image Files  /  tests  /  _support  
File Role Description
  Plain text file UnitTester.php Class Class source

 Version Control Unique User Downloads Download Rankings  
 100%
Total:43
This week:1
All time:10,807
This week:65Up