PHPackages                             alizharb/hookx - 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. alizharb/hookx

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

alizharb/hookx
==============

A next-generation, high-performance PHP 8.3+ hook and event system with async support.

v1.1.0(5mo ago)05MITPHPPHP ^8.3CI passing

Since Nov 26Pushed 5mo agoCompare

[ Source](https://github.com/AlizHarb/hookx)[ Packagist](https://packagist.org/packages/alizharb/hookx)[ GitHub Sponsors](https://github.com/alizharb)[ RSS](/packages/alizharb-hookx/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (7)Versions (3)Used By (0)

HookX
=====

[](#hookx)

[![Latest Version on Packagist](https://camo.githubusercontent.com/4606aabe160389e984a8a39a49a8077949c36fd644bd7b9c09914eead87e3207/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f616c697a686172622f686f6f6b782e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/alizharb/hookx)[![GitHub Tests Action Status](https://camo.githubusercontent.com/4fa47d765865e18fce5b16f8e3fe1a9cbeda41c901457bd4c55a275bcb3f9a34/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f416c697a486172622f686f6f6b782f74657374732e796d6c3f6c6162656c3d7465737473)](https://github.com/AlizHarb/hookx/actions?query=workflow%3Atests+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/0948cd5c970693e82737a3505cf75bc5a2257fe3982ebd2526d64b45022f1439/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f616c697a686172622f686f6f6b782e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/alizharb/hookx)[![License](https://camo.githubusercontent.com/cf71eb98d4146b246ed6ebb5b3eb938d3ac584c954bc94eba64ee49638ed80b1/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f616c697a686172622f686f6f6b782e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/alizharb/hookx)

**HookX** is a next-generation, high-performance PHP hook and event system designed for modern applications. Built on PHP 8.3+, it leverages **Attributes**, **Fibers**, and **Strong Typing** to deliver a developer experience that is both powerful and elegant.

✨ Features
----------

[](#-features)

- **Zero-Dependency**: Pure PHP implementation, no external bloat.
- **Async &amp; Background Hooks**: Run hooks in Fibers or push them to a Queue (Redis/Sync) using `#[Async]` and `#[Background]` attributes.
- **Framework Integrations**: Native support for **Laravel** and **Symfony**.
- **Developer Experience**: CLI tool (`bin/hookx`), REPL, and global helpers (`hook()`, `filter()`).
- **Advanced Matching**: Wildcards (`user.*`) and Regex (`#^order\.(created|updated)$#`) support.
- **Safety**: Immutable context, strict mode, and sandbox execution with time/memory limits.
- **Performance**: JIT compilation (experimental) and Zero-Copy dispatching.

📋 Requirements
--------------

[](#-requirements)

- PHP 8.3 or higher

📦 Installation
--------------

[](#-installation)

Install the package via Composer:

```
composer require alizharb/hookx
```

Documentation
-------------

[](#documentation)

- [**Basics**](docs/basics.md): Core concepts, HookManager, and Priorities.
- [**Async &amp; Queue**](docs/async.md): Background processing and Fibers.
- [**Advanced Usage**](docs/advanced.md): Wildcards, Regex, JIT, and Sandbox.
- [**CLI Tooling**](docs/cli.md): Using the `hookx` command-line tool.
- **Integrations**:
    - [**Laravel**](docs/laravel.md)
    - [**Symfony**](docs/symfony.md)
    - [**WordPress**](docs/wordpress.md)

Quick Start
-----------

[](#quick-start)

### Installation

[](#installation)

```
composer require alizharb/hookx
```

### Basic Usage

[](#basic-usage)

```
use AlizHarb\Hookx\Attributes\Hook;
use AlizHarb\Hookx\Context\HookContext;

class UserListener
{
    #[Hook('user.registered')]
    public function onRegister(HookContext $context): void
    {
        echo "User registered: " . $context->getArgument('email');
    }
}

// Register
$manager->registerObject(new UserListener());

// Dispatch
$manager->dispatch('user.registered', [
    'user' => ['name' => 'Alice', 'email' => 'alice@example.com']
]);
```

⚡ Async &amp; Background Hooks
------------------------------

[](#-async--background-hooks)

HookX supports both concurrent execution (Fibers) and true background processing (Queues).

```
use AlizHarb\Hookx\Async\AsyncHookDispatcher;

$dispatcher = new AsyncHookDispatcher($manager);

// Dispatches in background using Fibers
$dispatcher->dispatchAsync('email.send', [
    'to' => 'user@example.com',
    'subject' => 'Welcome!'
]);
```

For true background processing via Redis, check the [Async Documentation](docs/async.md).

📚 Documentation
---------------

[](#-documentation)

For comprehensive documentation, check the `docs/` directory:

- [Introduction](docs/introduction.md)
- [Installation](docs/installation.md)
- [Basic Usage](docs/basics.md)
- [Advanced Usage](docs/advanced.md)
- [CLI Tooling](docs/cli.md)
- [Async &amp; Background Hooks](docs/async.md)
- [Filters](docs/filters.md)
- [Framework Integrations](docs/integrations.md)

🧪 Testing
---------

[](#-testing)

Run the test suite:

```
composer test
```

📄 License
---------

[](#-license)

The MIT License (MIT). Please see [License File](LICENSE) for more information.

---

**Made with ❤️ by [Ali Harb](https://github.com/AlizHarb)**

###  Health Score

34

—

LowBetter than 77% of packages

Maintenance70

Regular maintenance activity

Popularity4

Limited adoption so far

Community2

Small or concentrated contributor base

Maturity51

Maturing project, gaining track record

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 ~2 days

Total

2

Last Release

171d ago

### Community

Maintainers

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

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/alizharb-hookx/health.svg)

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

PHPackages © 2026

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