netherphp/ki 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

netherphp/ki

最新稳定版本:v1.0.1

Composer 安装命令:

composer require netherphp/ki

包简介

An event handler

关键字:

README 文档

README

nether.io Code Climate Build Status Packagist Packagist

Basic Use

An event system handler. Queue callbacks to be executed when needed by other parts of the application. Can be used to trigger actions or filter things. Events are one time use by default, but you can also have them persist for multiple uses. This is not a true async thing like React - these filters will block, so they are safe for inline filtering.

Nether\Ki::Queue(string EventName, callable Callback, bool Persist default false);

Nether\Ki::Queue('my-first-event',function(){
	echo 'LOL EVENT LULZ';
	return;
});

That will queue an event to happen the first time we call it.

Nether\Ki::Flow(string EventName, array Args default null);

Nether\Ki::Flow('my-first-event');

After the first Flow, that event will be removed from the queue and additional flows will not proc it until you requeue it.

Rigging a Filter Event

To create a filter, you'll probably want to make a persistant event, with one of the few valid uses of pass-by-reference in PHP.

Nether\Ki::Queue('app-hates-at-signs',function(&$input){
	if(is_string($input)) $input = str_replace('@','',$input);
},true);

Then when you want to filter...

Nether\Ki::Flow('app-hates-at-signs',[&$text]);

And that filter will continue to work for the duration of the app.

Install

Use Composer.

"require": { "netherphp/ki":"~1.0.0" }

统计信息

  • 总下载量: 2.7k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 3
  • 依赖项目数: 3
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: BSD-2-Clause
  • 更新时间: 2014-03-23