edps / edps
PHP 5.2 port of Événement
v0.0.2
2012-10-24 14:10 UTC
Requires
- php: >=5.2.0
This package is auto-updated.
Last update: 2024-12-25 22:15:57 UTC
README
EDPS is a PHP 5.2 port of igorw's Événement.
Fetch
The recommended way to install EDPS is through composer.
Just create a composer.json file for your project:
{ "require": { "edps/edps": "dev-master" } }
And run these two commands to install it:
$ curl -s http://getcomposer.org/installer | php
$ php composer.phar install
Now you can add the autoloader, and you will have access to the library:
<?php require 'vendor/autoload.php';
Usage
Creating an Emitter
<?php $emitter = new Edps_EventEmitter();
Adding Listeners (>= PHP 5.3)
<?php $emitter->on('user.create', function (User $user) use ($logger) { $logger->log(sprintf("User '%s' was created.", $user->getLogin())); });
Adding Listeners (< PHP 5.3)
<?php $emitter->on('user.create', 'onUserCreate'); function onUserCreate(User $user) { global $logger; $logger->log(sprintf("User '%s' was created.", $user->getLogin())); }
Emitting Events
<?php $emitter->emit('user.create', array($user));
Tests
$ phpunit
License
MIT, see LICENSE.