承接 devriyad/hooks 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

devriyad/hooks

最新稳定版本:v0.1.4

Composer 安装命令:

composer require devriyad/hooks

包简介

Lightweight, synchronous, WordPress-style hook system for PHP, production-grade, type-safe and extensible.

README 文档

README

# riyad/hooks

> 🪝 A lightweight, synchronous, WordPress-style hook system for modern PHP — production-grade, extensible, and type-safe.

---

## 🚀 Features

✅ WordPress-style **actions** & **filters****Singleton** pattern for global consistency  
✅ Optional **functional helpers** (`add_action`, `apply_filters`, etc.)  
✅ **Enable/disable** helpers dynamically  
✅ **Clean OOP** design with interfaces  
✅ **Composer + PSR-4** compliant  
✅ **Production-ready**, no async or caching  

---

## 📦 Installation

```bash
composer require devriyad/hooks

Requires PHP ≥ 8.1

⚙️ Basic Usage

use Riyad\Hooks\Hook;

$hook = Hook::instance();

// Add an action
$hook->addAction('init', fn() => print "Initialized!\n");
$hook->doAction('init');

// Add a filter
$hook->addFilter('title', fn($title) => strtoupper($title));
echo $hook->applyFilters('title', 'hello world'); // HELLO WORLD

🧩 Enable Functional Helpers

$hook = Hook::instance();
$hook->enableHelpers();

add_action('boot', fn() => print "Booting...\n");
do_action('boot');

add_filter('message', fn($msg) => strtoupper($msg));
echo apply_filters('message', 'hello world');

🔧 Configuration

$hook->disableHelpers(); // Disable global functions
$hook->helpersEnabled(); // true or false
$hook->getDispatcher();  // Access underlying dispatcher

🧱 Architecture

devriyad-hooks/
├── src/
│   ├── Contracts/
│   │   └── EventInterface.php
│   │   └── DispatcherInterface.php
│   │   └── HookInterface.php
│   ├── Hook.php
│   ├── Dispatcher.php
│   ├── Event.php
│   ├── Listener.php
│   ├── ListenerCollection.php
│   ├── Helpers/functions.php
│   └── Exceptions/
│       ├── InvalidListenerException.php
│       └── EventDispatchException.php
├── docs/
│   ├── USAGE.md
│   └── DESIGN.md
├── composer.json
└── README.md

📘 Documentation

🧑‍💻 Author

Riyad Munauwar 📧 riyadmunauwar@gmail.com 📦 Package: devriyad/hooks

⚖️ License

Licensed under the MIT License. © 2025 Riyad Munauwar. All rights reserved.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-10-20