mirror of
https://github.com/rectorphp/rector.git
synced 2025-01-17 05:18:18 +01:00
c56fdd2b7f
1b68ff48b8
[automated] Apply Coding Standard (#6524)
É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.
Fetch
The recommended way to install Événement is through composer. By running the following command:
$ composer require evenement/evenement
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()));
});
Removing Listeners
<?php
$emitter->removeListener('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.