Événement

Événement 是一个非常简单的 PHP 事件调度库。「Événement is a very simple event dispatching library for PHP.」

  • Owner: igorw/evenement
  • Platform:
  • License:: MIT License
  • Category::
  • Topic:
  • Like:
    0
      Compare:

Github stars Tracking Chart

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

Build Status

Fetch

The recommended way to install Événement is through composer.

Just create a composer.json file for your project:

{
    "require": {
        "evenement/evenement": "^3.0, ^2.0"
    }
}

Note: The 3.x version of Événement requires PHP 7 and the 2.x version requires PHP 5.4. If you are
using PHP 5.3, please use the 1.x version:

{
    "require": {
        "evenement/evenement": "^1.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
require 'vendor/autoload.php';

Usage

Creating an Emitter

<?php
$emitter = new Evenement\EventEmitter();

Adding Listeners

<?php
$emitter->on('user.created', function (User $user) use ($logger) {
    $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.

Main metrics

Overview
Name With Ownerigorw/evenement
Primary LanguagePHP
Program languagePHP (Language Count: 1)
Platform
License:MIT License
所有者活动
Created At2011-08-16 19:14:57
Pushed At2024-12-28 18:30:43
Last Commit At2024-12-28 19:30:43
Release Count10
Last Release Namev3.0.2 (Posted on 2023-08-08 08:07:44)
First Release Namev0.1.0 (Posted on )
用户参与
Stargazers Count1.3k
Watchers Count31
Fork Count73
Commits Count204
Has Issues Enabled
Issues Count24
Issue Open Count2
Pull Requests Count48
Pull Requests Open Count1
Pull Requests Close Count18
项目设置
Has Wiki Enabled
Is Archived
Is Fork
Is Locked
Is Mirror
Is Private