PHPackages                             yurunsoft/yurun-event - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. yurunsoft/yurun-event

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

yurunsoft/yurun-event
=====================

A PHP Event Class Lib

v2.0.0(8y ago)62.5k22MITPHPPHP &gt;=5.4

Since Jun 8Pushed 8y ago2 watchersCompare

[ Source](https://github.com/Yurunsoft/YurunEvent)[ Packagist](https://packagist.org/packages/yurunsoft/yurun-event)[ RSS](/packages/yurunsoft-yurun-event/feed)WikiDiscussions master Synced 3w ago

READMEChangelog (5)DependenciesVersions (7)Used By (2)

YurunEvent
==========

[](#yurunevent)

PHP事件类，支持全局事件和在类中定义和使用事件。

Composer
========

[](#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目录。

###  Health Score

32

—

LowBetter than 69% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity22

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~78 days

Total

5

Last Release

2996d ago

Major Versions

v1.1.2 → v2.0.02018-04-17

### Community

Maintainers

![](https://www.gravatar.com/avatar/6f917bb42280d114c53cebadc2942a13ee03abe14971089f88895e266d637169?d=identicon)[Yurunsoft](/maintainers/Yurunsoft)

---

Top Contributors

[![Yurunsoft](https://avatars.githubusercontent.com/u/20104656?v=4)](https://github.com/Yurunsoft "Yurunsoft (12 commits)")

### Embed Badge

![Health badge](/badges/yurunsoft-yurun-event/health.svg)

```
[![Health](https://phpackages.com/badges/yurunsoft-yurun-event/health.svg)](https://phpackages.com/packages/yurunsoft-yurun-event)
```

###  Alternatives

[phabel/phabel

Write and deploy modern PHP 8 code, today.

24660.4k12](/packages/phabel-phabel)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
