-
Notifications
You must be signed in to change notification settings - Fork 0
getting started
Welcome to ArtisanPack UI Hooks. This guide will help you get up and running quickly.
See also: Actions, Filters, and Blade Directives.
- PHP 8.2+
- Laravel (tested with 10.x and 11.x)
Install via Composer:
composer require artisanpack-ui/hooksThis package supports Laravel’s package discovery and will automatically register:
- Service providers:
HooksServiceProvider,BladeDirectiveServiceProvider - Facade aliases:
Action,Filter
No manual changes to config/app.php are required in a standard Laravel app.
Register a callback on a named action and dispatch it later.
use function addAction;
use function doAction;
addAction('order.placed', function ($order) {
// Send email, fire a job, log, etc.
});
// Somewhere else in your code when the order is placed:
doAction('order.placed', $order);Read more in Actions.
Filters pass a value through one or more callbacks. Each callback receives the current value as the first argument and must return the (possibly modified) value.
use function addFilter;
use function applyFilters;
addFilter('price.display', function (string $price, string $currency) {
return $currency.' '.$price; // e.g., "USD 49.00"
});
$display = applyFilters('price.display', '49.00', 'USD');Read more in Filters.
Callbacks run in ascending priority order (lower numbers first). See Priorities and Execution Order.
Prefer Facades? Try Action and Filter. Rendering in Blade? Use @action and @filter. See Facades and Blade Directives.
Continue to Actions →