PHP Classes

Event router: Register event handlers and dispatch events

Recommend this page to a friend!
     
  Info   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: 44 All time: 10,815 This week: 40Up
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: 35
All time rank: 280778 in Russian Federation Russian Federation
Week rank: 12 Up1 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 (27)  
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 (27)  /  .github  
File Role Description
Files folder imageworkflows (1 file)

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

  Files folder image Files (27)  /  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 (27)  /  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 (27)  /  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 (27)  /  src  /  Exceptions  
File Role Description
  Plain text file EventRouterException.php Class Class source

  Files folder image Files (27)  /  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 (27)  /  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 (27)  /  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 (27)  /  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 (27)  /  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 (27)  /  tests  /  _support  
File Role Description
  Plain text file UnitTester.php Class Class source

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:44
This week:0
All time:10,815
This week:40Up