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(6mo ago)0332MITPHPPHP &gt;=8.1

Since Oct 20Pushed 6mo agoCompare

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

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

32

—

LowBetter than 72% of packages

Maintenance66

Regular maintenance activity

Popularity7

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity38

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

209d 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

[leafo/lessphp

lessphp is a compiler for LESS written in PHP.

2.2k8.2M141](/packages/leafo-lessphp)[realrashid/sweet-alert

Laravel Sweet Alert Is A Package For Laravel Provides An Easy Way To Display Alert Messages Using The SweetAlert2 Library.

1.2k2.9M21](/packages/realrashid-sweet-alert)[symfony/polyfill-php55

Symfony polyfill backporting some PHP 5.5+ features to lower PHP versions

10731.7M9](/packages/symfony-polyfill-php55)[helmich/typo3-typoscript-lint

Static code analysis for the TypoScript configuration language.

902.9M241](/packages/helmich-typo3-typoscript-lint)[cyclonedx/cyclonedx-php-composer

Creates CycloneDX Software Bill-of-Materials (SBOM) from PHP Composer projects

821.6M17](/packages/cyclonedx-cyclonedx-php-composer)[kartik-v/yii2-widget-touchspin

A Yii2 wrapper widget for the Bootstrap Switch plugin to use checkboxes &amp; radios as toggle touchspines (sub repo split from yii2-widgets)

184.1M6](/packages/kartik-v-yii2-widget-touchspin)

PHPackages © 2026

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