PHPackages                             devriyad/hooks - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. devriyad/hooks

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

devriyad/hooks
==============

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

v0.1.4(8mo ago)1392MITPHPPHP &gt;=8.1

Since Oct 20Pushed 8mo agoCompare

[ Source](https://github.com/riyadMunauwar/hooks)[ Packagist](https://packagist.org/packages/devriyad/hooks)[ RSS](/packages/devriyad-hooks/feed)WikiDiscussions master Synced today

READMEChangelogDependenciesVersions (7)Used By (2)

```
# 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
--------------

[](#️-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
---------------------------

[](#-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
---------------

[](#-configuration)

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

---

🧱 Architecture
--------------

[](#-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
---------------

[](#-documentation)

- [Usage Guide](./docs/USAGE.md)
- [Design Overview](./docs/DESIGN.md)

---

🧑‍💻 Author
----------

[](#‍-author)

**Riyad Munauwar**📧 📦 Package: `devriyad/hooks`

---

⚖️ License
----------

[](#️-license)

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

```

```

###  Health Score

30

—

LowBetter than 62% of packages

Maintenance60

Regular maintenance activity

Popularity7

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity39

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

5

Last Release

254d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/c085a838ff21f04484a7ee76f211557ba9e1151e85047a261e1bd0fb1845dc12?d=identicon)[riyadMunauwar](/maintainers/riyadMunauwar)

---

Top Contributors

[![riyadMunauwar](https://avatars.githubusercontent.com/u/56645541?v=4)](https://github.com/riyadMunauwar "riyadMunauwar (9 commits)")

### Embed Badge

![Health badge](/badges/devriyad-hooks/health.svg)

```
[![Health](https://phpackages.com/badges/devriyad-hooks/health.svg)](https://phpackages.com/packages/devriyad-hooks)
```

###  Alternatives

[cshaptx4869/html2word

html to word

131.0k](/packages/cshaptx4869-html2word)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
