rector/vendor/evenement/evenement
Tomas Votruba 66cc09e8b6 Updated Rector to commit d118ae38e265476684bcf566b87301cca5716ed9
d118ae38e2 Use phpstan-deprecation-rules (#3330)
2023-02-02 09:24:12 +00:00
..
doc Updated Rector to commit 21c9c1c16d 2021-11-23 13:20:36 +00:00
examples Updated Rector to commit d118ae38e265476684bcf566b87301cca5716ed9 2023-02-02 09:24:12 +00:00
src/Evenement Updated Rector to commit d118ae38e265476684bcf566b87301cca5716ed9 2023-02-02 09:24:12 +00:00
tests/Evenement/Tests Updated Rector to commit d118ae38e265476684bcf566b87301cca5716ed9 2023-02-02 09:24:12 +00:00
CHANGELOG.md Updated Rector to commit 21c9c1c16d 2021-11-23 13:20:36 +00:00
LICENSE Updated Rector to commit 21c9c1c16d 2021-11-23 13:20:36 +00:00
README.md Updated Rector to commit 21c9c1c16d 2021-11-23 13:20:36 +00:00
composer.json Updated Rector to commit d118ae38e265476684bcf566b87301cca5716ed9 2023-02-02 09:24:12 +00:00
phpunit.xml.dist Updated Rector to commit 21c9c1c16d 2021-11-23 13:20:36 +00:00

README.md

Événement

É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

Fetch

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 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 Evenement\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.