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
Requires
- php: ^8.3
- illuminate/console: ^12.0
- illuminate/container: ^12.0
- illuminate/pipeline: ^12.0
- illuminate/support: ^12.0
- illuminate/view: ^12.0
Requires (Dev)
- orchestra/testbench: ^10.0
- pestphp/pest: ^4.0
- pestphp/pest-plugin-laravel: ^4.0
README
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
BackedEnumsupport. - ๐ Async & Queued: Dispatch heavy actions to Laravel Queue via
Hook::queueAction. - ๐ Inspector & Debugbar: Real-time profiling with
laravel-debugbarintegration. - ๐ 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
- Basics: Actions, Filters, Priorities, and Attributes.
- Advanced Features: Typed Hooks, Wildcards, Scopes, Pipelines.
- Async & Queue: Background processing.
- Ecosystem & Safe DX: Signatures, Deprecations, IDE Helper, Compilation.
- Integrations: Debugbar, Eloquent, Blade.
- CLI Tooling: Artisan commands.
๐ 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