evenement / evenement
Événement is a very simple event dispatching library for PHP
Installs: 67 560 994
Dependents: 333
Suggesters: 3
Security: 0
Stars: 1 268
Watchers: 31
Forks: 72
Open Issues: 2
Requires
- php: >=7.0
Requires (Dev)
- phpunit/phpunit: ^9 || ^6
This package is not auto-updated.
Last update: 2024-09-08 06:59:18 UTC
README
É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', static function (User $user) use ($logger): void { $logger->log(sprintf("User '%s' was created.", $user->getLogin())); });
Removing Listeners
<?php $emitter->removeListener('user.created', static function (User $user) use ($logger): void { $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.