PHPackages                             quix-labs/laravel-hook-system - 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. quix-labs/laravel-hook-system

ActiveLibrary

quix-labs/laravel-hook-system
=============================

Add hooks system to Laravel

1.2.0(1y ago)031[5 PRs](https://github.com/quix-labs/laravel-hook-system/pulls)MITPHPPHP ^8.1CI passing

Since Jun 14Pushed 4mo ago1 watchersCompare

[ Source](https://github.com/quix-labs/laravel-hook-system)[ Packagist](https://packagist.org/packages/quix-labs/laravel-hook-system)[ GitHub Sponsors](https://github.com/alancolant)[ RSS](/packages/quix-labs-laravel-hook-system/feed)WikiDiscussions main Synced today

READMEChangelog (4)Dependencies (13)Versions (11)Used By (0)

Laravel Hook System
===================

[](#laravel-hook-system)

[![Latest Version on Packagist](https://camo.githubusercontent.com/ebac9257a398fb39599681ee3b224da29b937b84d78f939b8eaf653e7a797c02/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f717569782d6c6162732f6c61726176656c2d686f6f6b2d73797374656d2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/quix-labs/laravel-hook-system)[![GitHub Tests Action Status](https://camo.githubusercontent.com/eef75753b1887c076f24fdad8a89ee4731d9c6a150148251921f924a9bafccfc/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f717569782d6c6162732f6c61726176656c2d686f6f6b2d73797374656d2f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/quix-labs/laravel-hook-system/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/2c082770db507e4755b77758df9d26f2250b5afd0f8ebb7d96db2cf409d9e412/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f717569782d6c6162732f6c61726176656c2d686f6f6b2d73797374656d2f6669782d7068702d636f64652d7374796c652d6973737565732e796d6c3f6272616e63683d6d61696e266c6162656c3d636f64652532307374796c65267374796c653d666c61742d737175617265)](https://github.com/quix-labs/laravel-hook-system/actions?query=workflow%3A%22Fix+PHP+code+style+issues%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/4bd6fad28898ab9c2bb42daa7d8481d65dc1030ccc9d0aab7714d9a329ba0553/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f717569782d6c6162732f6c61726176656c2d686f6f6b2d73797374656d2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/quix-labs/laravel-hook-system)

---

The `quix-labs/laravel-hook-system` package provides a hook system for Laravel.

This system allows intercepting and manipulating specific actions in your application.

---

Requirements
------------

[](#requirements)

- PHP &gt;= 8.1
- Laravel 10.x|11.x|12.x

Installation
------------

[](#installation)

You can install this package via Composer:

```
composer require quix-labs/laravel-hook-system
```

Hook usage
----------

[](#hook-usage)

### Creating a Hook

[](#creating-a-hook)

A hook is a class that extends `QuixLabs\LaravelHookSystem\Hook`:

```
class GetString extends \QuixLabs\LaravelHookSystem\Hook
{
    public function __construct(public string &$string)
    {
    }
}
```

### Creating a Fully Cacheable Hook

[](#creating-a-fully-cacheable-hook)

Fully cacheable hooks execute interceptors during cache generation and prevent their execution at runtime. An interceptor can bypass this behavior.

```
class GetString extends \QuixLabs\LaravelHookSystem\Hook implements \QuixLabs\LaravelHookSystem\Interfaces\FullyCacheable
{
    public function __construct(public string &$string)
    {
    }

    public static function initialInstance(): static
    {
        $string = 'initial-state';
        return new static($string);
    }
}
```

### Registering Hooks

[](#registering-hooks)

In the `register` method of your ServiceProvider:

```
use Workbench\App\Hooks\GetString;

class YourProvider{
    public function register()
    {
        \QuixLabs\LaravelHookSystem\HookRegistry::registerHook(GetString::class);
    }
}
```

### Executing a Hook

[](#executing-a-hook)

To execute a hook, `QuixLabs\LaravelHookSystem\Hook` implements the static `send` method:

```
class YourController
{
    public function index()
    {
        $string = "";
        \Workbench\App\Hooks\GetString::send($string);
        return $string;
    }
}
```

Interceptor usage
-----------------

[](#interceptor-usage)

### Creating an Interceptor

[](#creating-an-interceptor)

An interceptor is a class with a static method intercepted via an `#[Intercept]` attribute:

```
use Illuminate\Support\Str;
use QuixLabs\LaravelHookSystem\Enums\ActionWhenMissing;
use QuixLabs\LaravelHookSystem\Utils\Intercept;

class AppendRandomString
{
    #[Intercept(\Workbench\App\Hooks\GetString::class)]
    public static function appendRandomString(GetString $hook): void
    {
        $hook->string .= Str::random(16);
    }

    # You can specify action when hook not found (THROW_ERROR, SKIP or REGISTER_HOOK)
    #[Intercept(\Workbench\App\Hooks\GetString::class, ActionWhenMissing::THROW_ERROR)]
    public static function appendStringRequired(GetString $hook): void
    {
        $hook->string .= Str::random(16);
    }

    # You can also specify execution priority using third argument
    #[Intercept(\Workbench\App\Hooks\GetString::class, ActionWhenMissing::SKIP, 100)]
    public static function appendRandomStringAtTheEnd(GetString $hook): void
    {
        $hook->string .= Str::random(16);
    }
    # You can prevent full cache generation (useful if the interceptor depends on context request)
    #[Intercept(\Workbench\App\Hooks\GetString::class, ActionWhenMissing::SKIP, 100, false)]
    public static function appendRandomStringAtTheEnd(GetString $hook): void
    {
        $hook->string .= Str::random(16);
    }
}
```

### Registering Interceptors

[](#registering-interceptors)

In the `boot` method of your ServiceProvider:

```
class YourProvider{
    public function boot()
    {
        \QuixLabs\LaravelHookSystem\HookRegistry::registerInterceptor(\App\Interceptors\AppendRandomString::class);
    }
}
```

Artisan Commands
----------------

[](#artisan-commands)

The package adds three Artisan commands to manage the hooks:

- `hooks:status` : Displays the status of hooks and interceptors.
- `hooks:cache` : Caches the hooks and interceptors.
- `hooks:clear` : Clears the hooks and interceptors cache.

Planned Features
----------------

[](#planned-features)

The following features are planned for future implementation:

- Instantiate interceptor class using `app()` (add support for dependency container injection).

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Credits
-------

[](#credits)

- [COLANT Alan](https://github.com/alancolant)
- [All Contributors](../../contributors)

License
-------

[](#license)

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

###  Health Score

36

↑

LowBetter than 83% of packages

Maintenance63

Regular maintenance activity

Popularity7

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity55

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 85% 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 ~88 days

Total

4

Last Release

381d ago

### Community

Maintainers

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

---

Top Contributors

[![alancolant](https://avatars.githubusercontent.com/u/19172637?v=4)](https://github.com/alancolant "alancolant (85 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (9 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (6 commits)")

---

Tags

hookinterceptorslaravellaravelHOOKinterceptor

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/quix-labs-laravel-hook-system/health.svg)

```
[![Health](https://phpackages.com/badges/quix-labs-laravel-hook-system/health.svg)](https://phpackages.com/packages/quix-labs-laravel-hook-system)
```

###  Alternatives

[rahulalam31/laravel-abuse-ip

Block ip address of all spammer's around the world.

27330.5k](/packages/rahulalam31-laravel-abuse-ip)[orptech/laravel-migration-partition

Laravel extensions that extends Illuminate to enable partitioned table creation within Laravel migrations.

3426.1k](/packages/orptech-laravel-migration-partition)

PHPackages © 2026

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