PHP Classes


Recommend this page to a friend!
  Classes of AlexanderC  >  Eventer  >  >  Download  
Role: Documentation
Content type: text/plain
Description: Auxiliary data
Class: Eventer
Register events and call handlers when they happen
Author: By
Last change: changed readme
changed readme
changed readme
changed readme
changed readme
added composer.json and moved classes to lib folder
edit readme
first commit
Date: 8 months ago
Size: 2,153 bytes


Class file image Download

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


 - No dependencies
 - Easy to use
 - Restful API
 - Latest PHP features usage
 - Well commented
 - ...much more...

 - PHP 5.5 and higher
 - awesomeness

 - Using composer(through packagist):

        "alexanderc/open-fw-eventer": "dev-master"

 - ... or simply load it using your autoloader (PSR-0 compliant)


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 = [

foreach($events as $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.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";
             new RegexMatcher('foo\..+\.event'),
             ['some', 'data', 'provided', 'to', 'each', 'listener']

// too much words??? check SimplifiedApiTrait...

OpenFW::Eventer php framework.

Copyright (C) 2013  AlexanderC
For more information send a message to info at phpclasses dot org.