Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Hooks Laravel Package

artisanpack-ui/hooks

WordPress-style actions and filters for Laravel with helper functions, Action and Filter facades, and Blade directives. Register callbacks on named hooks, run them in priority order, and remove them when needed.

View on GitHub
Deep Wiki
Context7

This package provides a flexible hook system for extending and customizing functionality throughout your application. It enables developers to tap into various points of the application lifecycle and add custom behavior without modifying core code.

Frequently asked questions about Hooks
What is artisanpack-ui/hooks and what problem does it solve in Laravel?
It provides WordPress-style named actions and filters for Laravel so you can attach custom behavior to extension points without modifying core code. Developers register callbacks with global helpers such as addAction and addFilter, the Action and Filter facades, or Blade directives. Callbacks run in priority order on named hooks, and removal and deprecation APIs are included.
How do I install and set up artisanpack-ui/hooks in a Laravel application?
Install it with composer require artisanpack-ui/hooks. Laravel package discovery registers the service providers and facade aliases automatically in a standard app. After installation, define your hook names and register callbacks with the helper functions, facades, or Blade directives.
Do I need to register service providers or edit config/app.php after installing this package?
No manual config/app.php edits are required in a standard Laravel app because package discovery registers HooksServiceProvider and BladeDirectiveServiceProvider. It also registers the Action and Filter facade aliases globally. Those alias names are very generic, so validate them against your existing facades and test helpers before adopting.
What is the difference between actions and filters in ArtisanPack UI Hooks?
Actions are fire-and-forget extension points: you register callbacks with addAction and trigger them with doAction for side effects like logging or dispatching jobs. Filters pass a value through an ordered callback chain: addFilter registers callbacks and applyFilters returns the modified value. Both use named hooks and the same priority ordering.
How do hook priorities determine callback execution order?
Callbacks run in ascending priority order, so lower numbers execute first and higher numbers execute later. The default priority is 10, so a callback registered at 5 runs before the default and one at 20 runs after it. Use explicit numbering when ordering matters, especially when multiple packages register on the same hook.
Can I use the Action and Filter facades or Blade directives, and are they safe?
Yes, the package provides Action and Filter facades plus @action and @filter Blade directives. However, @filter echoes the filter result directly and bypasses Blade's normal {{ }} escaping, so only use it for trusted, developer-controlled output. The global Action and Filter alias names are generic and may collide with existing app facades or test helpers.
How do I remove an action or filter callback, and why can't I remove inline closures?
removeAction and removeFilter compare the callable you pass against registered callbacks, so you must keep a reference to the exact callable. Inline anonymous closures passed directly to addAction or addFilter cannot be removed later because you have no reference to pass back. Store the closure in a variable or use removeAllActions and removeAllFilters when appropriate.
Which Laravel and PHP versions does artisanpack-ui/hooks support?
The README states PHP 8.2+ and Laravel 11.x, 12.x, or 13.x, with PHP 8.3+ required for Laravel 13. The technical assessment flags a test-matrix skew because CI standardized on PHP 8.4, so the claimed PHP 8.2 lower bound is effectively untested. Run your own PHP and Laravel matrix before pinning, and verify release provenance.
Is artisanpack-ui/hooks safe for production use with exceptions, recursion, and XSS?
It executes callbacks synchronously in the caller's stack, so an exception inside a callback propagates and can break the originating request or job; wrap risky work or dispatch queued jobs. The @filter Blade directive echoes the filter result without Blade's {{ }} escaping, so only use it for trusted, developer-controlled output. There is no documented re-entrancy guard, so avoid callbacks that re-dispatch the same hook.
Should I use artisanpack-ui/hooks instead of Laravel events and pipeline, and what are the maintenance risks?
For internal application decoupling, native Laravel events plus Illuminate\Pipeline\Pipeline are usually clearer and more statically analyzable. This package is most defensible for plugin-style ecosystems where third parties attach behavior to named extension points. Its adoption is effectively zero with a single maintainer, so treat it as a small dependency you may need to fork or vendor, and pair adoption with hook-name constants or enums plus tests because typo'd hook strings fail silently.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
marcelgwerder/laravel-api-handler
firebrikdotcom/conveyor-laravel-broadcaster
kanata-php/conveyor-laravel-broadcaster
alish/short-message
sonrac/lumen-league-oauth2
pushery/sanctum-hardening-for-laravel
evanschleret/laravel-uuidable
yigit-serin/laravel-openvidu
adachsoft/command-executor-lib
tagixo/document-builder
tagixo/page-builder
tagixo/mail-builder
tagixo/form-builder
primix/primix
tagixo/core
alesima/laravel-azure-service-bus
tomshaw/shopcart
likyly/laravel
darthsoup/shoppingcart
tdt/core