evenement:PHP事件分发库,简洁轻量,灵感源自Node.js EventEmitter

Événement is a very simple event dispatching library for PHP.

Branch4Tags10
FilesLast commitLast update
10 months ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
14 years ago
1 year ago
2 years ago
2 years ago

É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.

Continuous Integration Latest Stable Version Total Downloads License

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.

Introduction

Événement is a very simple event dispatching library for PHP.

Customize your domain
281.36 K72Visit GitHub