2017 © Pedro Peláez
 

library yurun-event

A PHP Event Class Lib

image

yurunsoft/yurun-event

A PHP Event Class Lib

  • Tuesday, April 17, 2018
  • by Yurunsoft
  • Repository
  • 1 Watchers
  • 6 Stars
  • 1,160 Installations
  • PHP
  • 3 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 7 Versions
  • 26 % Grown

The README.md

YurunEvent

PHP事件类,支持全局事件和在类中定义和使用事件。, (*1)

Composer

"require": {
    "yurunsoft/yurun-event" : "~2.0"
}

代码实例

全局事件

// 监听事件
Event::on('test', function($e){
    var_dump('trigger test', $e);
    $e['value'] = 'yurun';
});

// 一次性事件
Event::once('test1', function($e){
    var_dump('trigger test', $e);
    $e['value'] = $e['message'];
});

// 触发事件
Event::trigger('test', array('message'=>'666', 'value'=>&$value));

类中事件

class Test
{
    use ClassEvent;

    private $value;

    public function setValue($value)
    {
        $this->value = $value;
        $this->trigger('changeValue', array('value'=>$value));
    }
}

$test = new Test;
// 绑定事件
$test->on('changeValue', function($e){
    echo 'changeValue1:', $e['value'], PHP_EOL;
});
// 一次性事件
$test->once('changeValue', function($e){
    echo 'changeValue2:', $e['value'], PHP_EOL;
});
$test->setValue(123);
$test->setValue(456);

更详细的代码请至Demo目录。, (*2)

The Versions

17/04 2018

dev-master

9999999-dev

A PHP Event Class Lib

  Sources   Download

MIT

The Requires

  • php >=5.4

 

17/04 2018

dev-dev

dev-dev

A PHP Event Class Lib

  Sources   Download

MIT

The Requires

  • php >=5.4

 

17/04 2018

v2.0.0

2.0.0.0

A PHP Event Class Lib

  Sources   Download

MIT

The Requires

  • php >=5.4

 

17/04 2018

v1.1.2

1.1.2.0

  Sources   Download

MIT

The Requires

  • php >=5.4

 

14/08 2017

v1.1.1

1.1.1.0

  Sources   Download

MIT

11/08 2017

v1.1

1.1.0.0

  Sources   Download

08/06 2017

v1.0

1.0.0.0

  Sources   Download