定制 snowair/think-hookagent 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

snowair/think-hookagent

最新稳定版本:v0.4

Composer 安装命令:

composer require snowair/think-hookagent

包简介

ThinkPHP3.2 composer扩展包开发工具

README 文档

README

ThinkPHP的扩展在使用时,往往需要增加行为配置即一些应用配置. 这需要用户手动处理.

HookAgent的作用就是为有此类需要的扩展包提供一个注入行为的统一入口, 使用HookAgent开发的扩展包, 最终用户只需要在 Common/Conf/tags.php 增加一个行为,即可:

return array(
 'app_init'=>array(
     'Snowair\Think\Behavior\HookAgent',
 ),
)

开发

如果你的thinkphp composer包需要注入行为, 只需要创建类似这样的文件:

<?php
// include.php
if (class_exists( 'Snowair\Think\Behavior\HookAgent' )) {
    \Snowair\Think\Behavior\HookAgent::add('app_begin','Snowair\\Dotenv\\DotEnv');
}

然后在包的composer.json文件中加入require和autoload设置:

{
  "name": "xxx/xxx",
  "require": {
    "snowair/think-hookagent": ">=0.1"
  },
  "autoload": {
    "files": ["include.php"]
  }
}
  • 注意: 你只能借助HookAgent从 app_begin 往后开始注入行为. 你无法通过HookAgent向app_init注入行为.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-09-08