定制 peridot-php/event-emitter 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

peridot-php/event-emitter

Composer 安装命令:

composer require peridot-php/event-emitter

包简介

EventEmitter is a very simple event dispatching library for PHP

README 文档

README

EventEmitter is a very simple event dispatching library for PHP. It is a fork of Événement 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.

Build Status

Fetch

The recommended way to install EventEmitter is through composer.

Just create a composer.json file for your project:

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

Usage

Creating an Emitter

<?php
$emitter = new Peridot\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.

统计信息

  • 总下载量: 648
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 9
  • 点击次数: 0
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 9
  • Watchers: 4
  • Forks: 6
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-04-18