PHP Classes

Event router: Register event handlers and dispatch events

Recommend this page to a friend!

  Author Author  
Picture of Smoren  Freelight
Name: Smoren Freelight <contact>
Classes: 16 packages by
Country: Russian Federation Russian Federation
Innovation award
Innovation award
Nominee: 6x


  Detailed description   Download Download .zip .tar.gz  
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.

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

  Classes of Smoren Freelight  >  Event router  >  Download Download .zip .tar.gz  >  Support forum Support forum  >  Blog Blog  >  RSS 1.0 feed RSS 2.0 feed Latest changes  
Name: Event router
Base name: event-router-php
Description: Register event handlers and dispatch events
Version: -
PHP version: 7.4
License: MIT/X Consortium License
 
  Groups   Applications   Files Files  

  Groups  
Group folder image Algorithms Numerical and statistical algorithms View top rated classes
Group folder image Libraries Frameworks and libraries of cooperating classes View top rated classes
Group folder image Language Constructs to assist in the language control View top rated classes
Group folder image PHP 7 Classes using PHP 7 specific features View top rated classes


  Applications that use this package  
No pages of applications that use this class were specified.

Add link image If you know an application of this package, send a message to the author to add a link here.

  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

Download Download all files: event-router-php.tar.gz event-router-php.zip
NOTICE: if you are using a download manager program like 'GetRight', please Login before trying to download this archive.
  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

Download Download all files: event-router-php.tar.gz event-router-php.zip
NOTICE: if you are using a download manager program like 'GetRight', please Login before trying to download this archive.