laravel-hooks maintained by alizharb
Laravel Hooks
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). - 🧬 Model Extensions: Declarative model extensions via Attributes or
Hook::model()API. - 🛡️ Type-Safe: Strict signatures contracts,
BackedEnum, and DTO support. - 🚦 Circuit Breaker: request-level failure protection for critical hooks.
- 🚀 Async & Queued: Dispatch heavy actions to Laravel Queue via
Hook::queueAction. - 🔍 Inspector & Debugbar: Real-time profiling with
laravel-debugbarintegration. - 📊 Pulse Integration: Performance monitoring and hit counts via Laravel Pulse.
- 📦 Ecosystem Ready: Pipelines, Deprecations, IDE Help, and Auto-Docs generator.
📦 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
🌏 Ecosystem
Laravel Hooks is part of a larger ecosystem designed for modular, extensible Laravel applications:
- Laravel Modular: Build modular Laravel apps with zero configuration.
- Laravel Themer: A powerful theme engine for Laravel applications.
- Filament Modular Luncher: The ultimate dashboard launcher for modular projects.
- Filament Themer Luncher: Professional theme switching for Filament.
- Modular JS: Seamless asset management for Laravel modules.
- First-class bridges for Filament and Livewire.
💖 Sponsors
If you find this package useful, please consider supporting its development:
📄 License
The MIT License (MIT). Please see License File for more information.
Made with ❤️ by Ali Harb