PHP Classes

Eventer: Register events and call handlers when they happen

Recommend this page to a friend!
  Info   View files View files (9)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2024-01-09 (4 days ago) RSS 2.0 feedNot yet rated by the usersTotal: 251 This week: 2All time: 7,896 This week: 220Up
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 <contact>
Classes: 13 packages by
Country: Moldova Moldova
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  
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  /  lib  
File Role Description
Files folder imageOpenFW (1 directory)

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

  Files folder image Files  /  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  /  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  /  lib  /  OpenFW  /  Events  /  Traits  
File Role Description
  Plain text file SimplifiedApiTrait.php Class Class source

 Version Control Unique User Downloads Download Rankings  
 100%
Total:251
This week:2
All time:7,896
This week:220Up