alizharb / laravel-hooks
A universal extensibility and plugin system for Laravel 12 applications.
Fund package maintenance!
AlizHarb
Installs: 15
Dependents: 0
Suggesters: 6
Security: 0
Stars: 7
Watchers: 0
Forks: 1
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)
- filament/filament: ^4.0|^5.0
- friendsofphp/php-cs-fixer: *
- fruitcake/laravel-debugbar: ^4.0
- larastan/larastan: ^3.9
- laravel/pint: ^1.24
- laravel/pulse: ^1.2
- livewire/livewire: ^4.0
- orchestra/testbench: ^9.5|^10.0
- pestphp/pest: *
- pestphp/pest-plugin-laravel: *
- phpstan/phpstan: *
Suggests
- alizharb/filament-modular-luncher: Advanced Filament dashboard launcher for modular projects.
- alizharb/filament-themer-luncher: Theme management integration for Filament dashboards.
- alizharb/laravel-modular: Build modular Laravel apps with zero configuration.
- alizharb/laravel-modular-filament: Filament v5 admin panel integration for modules.
- alizharb/laravel-modular-js: Zero-config JavaScript and assets management for modules.
- alizharb/laravel-modular-livewire: Automatic Livewire component discovery and registration.
- alizharb/laravel-themer: A powerful theme engine for Laravel applications.
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). - ๐งฌ 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