![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/old/vendor/rector/rector/vendor/evenement/evenement/ |
# Événement Événement is a very simple event dispatching library for PHP. It has the same design goals as [Silex](https://silex.symfony.com/) and [Pimple](https://github.com/silexphp/Pimple), to empower the user while staying concise and simple. It is very strongly inspired by the [EventEmitter](https://nodejs.org/api/events.html#events_class_eventemitter) API found in [node.js](http://nodejs.org).  [](https://packagist.org/packages/evenement/evenement) [](https://packagist.org/packages/evenement/evenement/stats) [](https://packagist.org/packages/evenement/evenement) ## Fetch The recommended way to install Événement is [through composer](http://getcomposer.org). By running the following command: $ composer require evenement/evenement ## Usage ### Creating an Emitter ```php <?php $emitter = new Evenement\EventEmitter(); ``` ### Adding Listeners ```php <?php $emitter->on('user.created', function (User $user) use ($logger) { $logger->log(sprintf("User '%s' was created.", $user->getLogin())); }); ``` ### Removing Listeners ```php <?php $emitter->removeListener('user.created', function (User $user) use ($logger) { $logger->log(sprintf("User '%s' was created.", $user->getLogin())); }); ``` ### Emitting Events ```php <?php $emitter->emit('user.created', [$user]); ``` Tests ----- $ ./vendor/bin/phpunit License ------- MIT, see LICENSE.