alizharb/laravel-hooks

A universal extensibility and plugin system for Laravel 12 applications.

Installs: 2

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 0

Forks: 0

Open Issues: 0

pkg:composer/alizharb/laravel-hooks

v1.0.0 2026-01-14 21:46 UTC

This package is auto-updated.

Last update: 2026-01-15 09:02:56 UTC


README

Latest Version on Packagist GitHub Tests Action Status License

Laravel Hooks is a production-ready, universal extensibility system for Laravel 12. Inspired by WordPress but modernized with PHP 8.5 attributes, Strict Typing, and Deep Laravel Integration.

โœจ Features

  • โšก Actions & Filters: High-performance hook system (addAction, applyFilters).
  • ๐Ÿงฌ Attribute-based: Register hooks via #[HookAction] and #[HookFilter].
  • ๐Ÿ›ก๏ธ Type-Safe: Strict signatures contracts and BackedEnum support.
  • ๐Ÿš€ Async & Queued: Dispatch heavy actions to Laravel Queue via Hook::queueAction.
  • ๐Ÿ” Inspector & Debugbar: Real-time profiling with laravel-debugbar integration.
  • ๐ŸŒˆ Context Aware: Scoped hooks for specific instances (Hook::for($model)).
  • ๐Ÿ“ฆ Ecosystem Ready: Pipelines, Deprecations, IDE Help, and Compilation.

๐Ÿ“ฆ Installation

composer require alizharb/laravel-hooks

๐Ÿ“š Documentation

๐Ÿš€ Quick Start

Basic Usage

use AlizHarb\LaravelHooks\Facades\Hook;

// Register
Hook::addAction('order.created', function ($order) {
    Log::info("Order #{$order->id} created");
});

// Dispatch
Hook::doAction('order.created', $order);

Attribute Registration

use AlizHarb\LaravelHooks\Attributes\HookFilter;

class contentModifier
{
    #[HookFilter('content.render', priority: 20)]
    public function addSignature($content)
    {
        return $content . "\n\n-- Sent via Laravel Hooks";
    }
}

๐Ÿงช Testing

Run the test suite:

composer test

๐Ÿ“„ License

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

Made with โค๏ธ by Ali Harb