{"id":15374313,"url":"https://github.com/yurunsoft/yurunevent","last_synced_at":"2026-02-28T07:06:21.215Z","repository":{"id":57088801,"uuid":"93699571","full_name":"Yurunsoft/YurunEvent","owner":"Yurunsoft","description":"PHP事件类，支持全局事件和类中事件。程序员Q群：74401592","archived":false,"fork":false,"pushed_at":"2018-04-17T02:29:46.000Z","size":13,"stargazers_count":6,"open_issues_count":0,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-28T21:38:18.848Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://git.oschina.net/yurunsoft/yurunevent","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Yurunsoft.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-06-08T02:32:52.000Z","updated_at":"2024-12-16T05:39:14.000Z","dependencies_parsed_at":"2022-08-20T15:30:15.835Z","dependency_job_id":null,"html_url":"https://github.com/Yurunsoft/YurunEvent","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Yurunsoft%2FYurunEvent","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Yurunsoft%2FYurunEvent/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Yurunsoft%2FYurunEvent/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Yurunsoft%2FYurunEvent/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Yurunsoft","download_url":"https://codeload.github.com/Yurunsoft/YurunEvent/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249094932,"owners_count":21211837,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-01T13:58:19.544Z","updated_at":"2026-02-28T07:06:21.146Z","avatar_url":"https://github.com/Yurunsoft.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# YurunEvent\r\n\r\nPHP事件类，支持全局事件和在类中定义和使用事件。\r\n\r\n# Composer\r\n\r\n```json\r\n\"require\": {\r\n    \"yurunsoft/yurun-event\" : \"~2.0\"\r\n}\r\n```\r\n\r\n# 代码实例\r\n\r\n## 全局事件\r\n\r\n```php\r\n// 监听事件\r\nEvent::on('test', function($e){\r\n\tvar_dump('trigger test', $e);\r\n\t$e['value'] = 'yurun';\r\n});\r\n\r\n// 一次性事件\r\nEvent::once('test1', function($e){\r\n\tvar_dump('trigger test', $e);\r\n\t$e['value'] = $e['message'];\r\n});\r\n\r\n// 触发事件\r\nEvent::trigger('test', array('message'=\u003e'666', 'value'=\u003e\u0026$value));\r\n```\r\n\r\n## 类中事件\r\n\r\n```php\r\nclass Test\r\n{\r\n\tuse ClassEvent;\r\n\r\n\tprivate $value;\r\n\r\n\tpublic function setValue($value)\r\n\t{\r\n\t\t$this-\u003evalue = $value;\r\n\t\t$this-\u003etrigger('changeValue', array('value'=\u003e$value));\r\n\t}\r\n}\r\n\r\n$test = new Test;\r\n// 绑定事件\r\n$test-\u003eon('changeValue', function($e){\r\n\techo 'changeValue1:', $e['value'], PHP_EOL;\r\n});\r\n// 一次性事件\r\n$test-\u003eonce('changeValue', function($e){\r\n\techo 'changeValue2:', $e['value'], PHP_EOL;\r\n});\r\n$test-\u003esetValue(123);\r\n$test-\u003esetValue(456);\r\n```\r\n\r\n更详细的代码请至Demo目录。","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyurunsoft%2Fyurunevent","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyurunsoft%2Fyurunevent","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyurunsoft%2Fyurunevent/lists"}