peridot-php/event-emitter

EventEmitter is a very simple event dispatching library for PHP

Maintainers

👁 brianium

Package info

github.com/peridot-php/event-emitter

pkg:composer/peridot-php/event-emitter

Statistics

Installs: 938

Dependents: 1

Suggesters: 0

Stars: 9

Open Issues: 1

dev-master / 2.0.x-dev 2015-04-18 16:26 UTC

Requires

  • php: >=5.6.0

Requires (Dev)

Suggests

None

Provides

None

Conflicts

None

Replaces

None

MIT a2a78de234a17e4a383af8b8eaafe70cba68a3a1

  • Igor Wiedler <igor.woop@wiedler.ch>
  • Brian Scaturro <scaturrob.woop@gmail.com>

event-dispatcherevent-emitter

This package is not auto-updated.

Last update: 2026-06-21 03:23:32 UTC


README

EventEmitter is a very simple event dispatching library for PHP. It is a fork of Événement aiming to provide additional functionality and PHP 5.6 features like variadic arguments.

It is very strongly inspired by the EventEmitter API found in node.js.

👁 Build Status

Fetch

The recommended way to install EventEmitter is through composer.

Just create a composer.json file for your project:

{
 "require": {
 "peridot/event-emitter": "2.0.*"
 }
}

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 Peridot\EventEmitter();

Adding Listeners

<?php
$emitter->on('user.created', function (User $user) use ($logger) {
 $logger->log(sprintf("User '%s' was created.", $user->getLogin()));
});

Emitting Events

<?php
$emitter->emit('user.created', $user);

Tests

$ vendor/bin/phpunit

License

MIT, see LICENSE.