php 事件调度,Événement 一个非常简单的事件调度PHP库

Événément是一款简洁高效的PHP事件调度库,其设计目标与Silex和Pimple相似,旨在为用户提供强大的功能同时保持简洁性和简单性。该库深受node.js中的EventEmitter API启发。
摘要由CSDN通过智能技术生成

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

fe44b3258673fd62513c87cdce0d83d2.png

Fetch

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

Just create a composer.json file for your project:

{

"require": {

"evenement/evenement": "2.0.*"

}

}

Note: The 2.0.* version of Événement requires PHP 5.4. If you are using PHP 5.3, please use the 1.0.* 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:

require 'vendor/autoload.php';

Usage

Creating an Emitter

$emitter = new Evenement\EventEmitter();

Adding Listeners

$emitter->on('user.created', function (User $user) use ($logger) {

$logger->log(sprintf("User '%s' was created.", $user->getLogin()));

});

Emitting Events

$emitter->emit('user.created', array($user));

Tests

$ phpunit

License

MIT, see LICENSE.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值