PHP Classes

Eventer: Register events and call handlers when they happen

Recommend this page to a friend!
     
  Info   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2024-01-09 (9 months ago) RSS 2.0 feedNot enough user ratingsTotal: 253 All time: 7,887 This week: 69Up
Version License PHP version Categories
eventer 1.0.0GNU General Publi...5.5PHP 5, Language
Description 

Author

This package can register events and call handlers when they happen.

It can register several types of events given their names.

It can also register event listener functions that will be called when the events happen.

The event listeners may be called when they match an event by the exact name or by matching a regular expression.

An event listener may be called only the first time it happens or every time.

Picture of AlexanderC
  Performance   Level  
Name: AlexanderC is available for providing paid consulting. Contact AlexanderC .
Classes: 13 packages by
Country: Moldova Moldova
Age: 35
All time rank: 7301 in Moldova Moldova
Week rank: 240 Up2 in Moldova Moldova Down
Innovation award
Innovation award
Nominee: 3x

Details

OpenFW::Eventer =============== It is a library used by OpenFW framework. Eventer- is an event manager that makes your life easier when using event driven development. There are a lot of libraries doing this, but not that beautifully ;) Advantages ========== - No dependencies - Easy to use - Restful API - Latest PHP features usage - Well commented - ...much more... Requirements ============ - PHP 5.5 and higher - awesomeness Installation ============ - Using composer(through packagist): "alexanderc/open-fw-eventer": "dev-master" - ... or simply load it using your autoloader (PSR-0 compliant) Example ======= ```php <?php use OpenFW\Events\Eventer; use OpenFW\Events\Event; use OpenFW\Events\Matchers\BinaryMatcher; use OpenFW\Events\Matchers\RegexMatcher; use OpenFW\Events\Traits\SimplifiedApiTrait; $eventer = new Eventer(); $events = [ 'foo.bar.event', 'foo.baz.smth', 'foo.habra.event', 'smth.habra.post' ]; foreach($events as $event) { $eventer->register($event); } echo "Adding some listeners\n"; $eventer->addListener(new BinaryMatcher('foo.habra.event'), function(Event $event) { echo sprintf("This will be called on %s event only\n", $event); }); $eventer->addListener(new RegexMatcher('.+\.habra\..+'), function(Event $event) { echo sprintf("Wow, calling habra events! (%s)\n", $event); }); $eventer->addOnceListener(new RegexMatcher('foo\..+\.event'), function(Event $event) { echo sprintf("This event is one of [foo.bar.event, foo.habra.event] -> %s. ", $event), "Also this is thrown only once!\n"; }); echo "Trigger all events once using binary matcher\n"; foreach($events as $event) { $eventer->trigger($event, ['some', 'data', 'provided', 'to', 'each', 'listener']); } echo "Trigger all events that matches against an RegexMatcher\n"; $eventer->triggerUsingMatcher( new RegexMatcher('foo\..+\.event'), ['some', 'data', 'provided', 'to', 'each', 'listener'] ); // too much words??? check SimplifiedApiTrait... ``` Credentials =========== OpenFW::Eventer php framework. Copyright (C) 2013 AlexanderC

  Files folder image Files (9)  
File Role Description
Files folder imagelib (1 directory)
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file LICENSE Lic. Auxiliary data
Accessible without login Plain text file README.md Doc. Auxiliary data

  Files folder image Files (9)  /  lib  
File Role Description
Files folder imageOpenFW (1 directory)

  Files folder image Files (9)  /  lib  /  OpenFW  
File Role Description
Files folder imageEvents (2 files, 2 directories)

  Files folder image Files (9)  /  lib  /  OpenFW  /  Events  
File Role Description
Files folder imageMatchers (3 files)
Files folder imageTraits (1 file)
  Plain text file Event.php Class Class source
  Plain text file Eventer.php Class Main event manager class

  Files folder image Files (9)  /  lib  /  OpenFW  /  Events  /  Matchers  
File Role Description
  Plain text file AbstractMatcher.php Class Class source
  Plain text file BinaryMatcher.php Class Class source
  Plain text file RegexMatcher.php Class Class source

  Files folder image Files (9)  /  lib  /  OpenFW  /  Events  /  Traits  
File Role Description
  Plain text file SimplifiedApiTrait.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:253
This week:0
All time:7,887
This week:69Up