定制 f4php/hookmanager 二次开发

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

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

f4php/hookmanager

最新稳定版本:v0.0.2

Composer 安装命令:

composer require f4php/hookmanager

包简介

HookManager is internal hooks core package for F4, a lightweight web development framework

README 文档

README

HookManager is an internal hooks core package for F4, a lightweight web development framework.

It is primarily used by F4 for collecting performance information to be displayed in debug mode.

Example Usage

HookManager uses a very simple API to register and invoke app-wide event handlers:

/*
 * The first step is to register a hook handler for an arbitrary hook name.
 * 
 * HookManager includes a set of hook names defined as constants looking like this:
 * 
 *  HookManager::BEFORE_*
 *  HookManager::AFTER_*
 * 
 * which are used by F4 internally.
 */
HookManager::addHook('hook name', function (array $context): bool {
    // do something useful
    return true;
});

// ...

/*
 * Once registered, hooks may be invoked (triggered) anywhere in the code.
 * 
 * This call will always return an array containing return values
 * from all registered handlers. If no handlers were registered, it will return an empty array.
 */
HookManager::triggerHook('hook name', ['context' => null]); // returns: [ 0 => true ]

统计信息

  • 总下载量: 46
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 1
  • 依赖项目数: 2
  • 推荐数: 0

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-07-05