https://github.com/peridot-php/event-emitter
A very simple event dispatching library for PHP.
https://github.com/peridot-php/event-emitter
Last synced: about 1 year ago
JSON representation
A very simple event dispatching library for PHP.
- Host: GitHub
- URL: https://github.com/peridot-php/event-emitter
- Owner: peridot-php
- License: mit
- Created: 2015-04-16T23:21:05.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2015-04-18T16:26:52.000Z (about 11 years ago)
- Last Synced: 2025-05-07T21:04:54.590Z (about 1 year ago)
- Language: PHP
- Size: 180 KB
- Stars: 9
- Watchers: 5
- Forks: 6
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# EventEmitter
EventEmitter is a very simple event dispatching library for PHP. It is a fork of
[Événement](https://github.com/igorw/evenement) aiming to provide additional functionality
and PHP 5.6 features like variadic arguments.
It is very strongly inspired by the EventEmitter API found in
[node.js](http://nodejs.org).
[](http://travis-ci.org/peridot-php/event-emitter)
## Fetch
The recommended way to install EventEmitter is [through composer](http://getcomposer.org).
Just create a composer.json file for your project:
```JSON
{
"require": {
"peridot/event-emitter": "2.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
on('user.created', function (User $user) use ($logger) {
$logger->log(sprintf("User '%s' was created.", $user->getLogin()));
});
```
### Emitting Events
```php
emit('user.created', $user);
```
Tests
-----
$ vendor/bin/phpunit
License
-------
MIT, see LICENSE.