PHP Classes

File: vendor/evenement/evenement/

Recommend this page to a friend!
  Classes of butani kartik  >  PHP WebSockets Server Example  >  vendor/evenement/evenement/  >  Download  
File: vendor/evenement/evenement/
Role: Example script
Content type: text/markdown
Description: Example script
Class: PHP WebSockets Server Example
Example to interact with a server using WebSockets
Author: By
Last change:
Date: 2 months ago
Size: 1,612 bytes


Class file image Download


Événement is a very simple event dispatching library for PHP.

It has the same design goals as Silex and Pimple, to empower the user while staying concise and simple.

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

Build Status


The recommended way to install Événement is through composer.

Just create a composer.json file for your project:

    "require": {
        "evenement/evenement": "^3.0 || ^2.0"

Note: The 3.x version of Événement requires PHP 7 and the 2.x version requires PHP 5.4. If you are using PHP 5.3, please use the 1.x version:

    "require": {
        "evenement/evenement": "^1.0"

And run these two commands to install it:

$ curl -s | php
$ php composer.phar install

Now you can add the autoloader, and you will have access to the library:

require 'vendor/autoload.php';


Creating an Emitter

$emitter = new Evenement\EventEmitter();

Adding Listeners

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

Emitting Events

$emitter->emit('user.created', [$user]);


$ ./vendor/bin/phpunit



For more information send a message to info at phpclasses dot org.