Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/igorw/evenement
Événement is a very simple event dispatching library for PHP.
https://github.com/igorw/evenement
Last synced: 2 days ago
JSON representation
Événement is a very simple event dispatching library for PHP.
- Host: GitHub
- URL: https://github.com/igorw/evenement
- Owner: igorw
- License: mit
- Created: 2011-08-16T19:14:57.000Z (over 13 years ago)
- Default Branch: master
- Last Pushed: 2024-07-08T16:04:22.000Z (5 months ago)
- Last Synced: 2024-10-29T10:55:26.949Z (about 1 month ago)
- Language: PHP
- Homepage:
- Size: 146 KB
- Stars: 1,277
- Watchers: 31
- Forks: 73
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
- favorite-link - Événement 是一个非常简单的 PHP 事件调度库。
- awesome-php - Evenement - An event dispatcher library. (Table of Contents / Event)
- awesome-php-cn - Evenement - 事件调度程序库. (目录 / 事件 Event)
- awesome-projects - Evenement - An event dispatcher library. (PHP / Event)
- awesome-php - Evenement - An event dispatcher library. (Table of Contents / Event)
README
# É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).![Continuous Integration](https://github.com/igorw/evenement/workflows/CI/badge.svg)
[![Latest Stable Version](https://poser.pugx.org/evenement/evenement/v/stable.png)](https://packagist.org/packages/evenement/evenement)
[![Total Downloads](https://poser.pugx.org/evenement/evenement/downloads.png)](https://packagist.org/packages/evenement/evenement/stats)
[![License](https://poser.pugx.org/evenement/evenement/license.png)](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:
```bash
$ composer require evenement/evenement
```## Usage
### Creating an Emitter
```php
on('user.created', static function (User $user) use ($logger): void {
$logger->log(sprintf("User '%s' was created.", $user->getLogin()));
});
```### Removing Listeners
```php
removeListener('user.created', static function (User $user) use ($logger): void {
$logger->log(sprintf("User '%s' was created.", $user->getLogin()));
});
```### Emitting Events
```php
emit('user.created', [$user]);
```Tests
-----
```bash
$ ./vendor/bin/phpunit
```License
-------
MIT, see LICENSE.