PHPackages                             artisanpack-ui/hooks - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. artisanpack-ui/hooks

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

artisanpack-ui/hooks
====================

WordPress-style actions and filters for Laravel, with Blade directives and helper functions.

1.2.1(3w ago)01.6k[2 issues](https://github.com/ArtisanPack-UI/hooks/issues)5MITPHPPHP ^8.2

Since Oct 16Pushed 3w agoCompare

[ Source](https://github.com/ArtisanPack-UI/hooks)[ Packagist](https://packagist.org/packages/artisanpack-ui/hooks)[ RSS](/packages/artisanpack-ui-hooks/feed)WikiDiscussions main Synced today

READMEChangelog (4)Dependencies (18)Versions (6)Used By (5)

ArtisanPack UI Hooks
====================

[](#artisanpack-ui-hooks)

WordPress-style actions and filters for Laravel applications — with convenient helper functions, Facades, and Blade directives.

This package lets you register callbacks on named hooks (actions) and filter values (filters) anywhere in your app. It’s great for modular packages, plug-in style extensions, and clean separation of concerns.

Table of contents
-----------------

[](#table-of-contents)

- Features
- Requirements
- Installation
- Laravel package discovery
- Quick start
    - Actions
    - Filters
- Priorities and execution order
- Using Facades
- Blade directives
- Testing locally
- Contributing
- Security
- Changelog
- License

Features
--------

[](#features)

- Simple API for registering and dispatching actions and filters
- Helper functions: `addAction`, `doAction`, `removeAction` (since 1.1.0), `removeAllActions` (since 1.1.0), `addFilter`, `applyFilters`, `removeFilter` (since 1.1.0), `removeAllFilters` (since 1.1.0)
- Static Facades for Laravel: `Action` and `Filter`
- Blade directives: `@action` and `@filter`
- Runs callbacks in predictable priority order (lower numbers first)
- Fully framework-native for Laravel with auto-discovery

Requirements
------------

[](#requirements)

- PHP 8.2+ (PHP 8.3+ required when using Laravel 13)
- Laravel 11.x, 12.x, or 13.x

Installation
------------

[](#installation)

Install via Composer:

```
composer require artisanpack-ui/hooks
```

Laravel package discovery
-------------------------

[](#laravel-package-discovery)

This 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.

Quick start
-----------

[](#quick-start)

### Actions

[](#actions)

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);
```

You can also provide a priority (lower numbers run first; default is 10):

```
addAction('order.placed', fn () => logger('low priority first'), 5);
addAction('order.placed', fn () => logger('default priority next')); // 10
addAction('order.placed', fn () => logger('higher number last'), 20);
```

#### Removing action callbacks (since 1.1.0)

[](#removing-action-callbacks-since-110)

```
use function removeAction;
use function removeAllActions;

$callback = fn () => logger('temp');

addAction('order.placed', $callback);

// Remove a specific callback
$removed = removeAction('order.placed', $callback); // true

// Remove all callbacks at a given priority
removeAllActions('order.placed', 20);

// Remove all callbacks for the hook
removeAllActions('order.placed');
```

### Filters

[](#filters)

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');
```

#### Removing filter callbacks (since 1.1.0)

[](#removing-filter-callbacks-since-110)

```
use function removeFilter;
use function removeAllFilters;

$fn = fn (string $v) => strtoupper($v);

addFilter('text.process', $fn, 20);

// Remove a specific callback
$ok = removeFilter('text.process', $fn); // true

// Remove all callbacks at a given priority
removeAllFilters('text.process', 20);

// Remove all callbacks for the hook
removeAllFilters('text.process');
```

Priorities and execution order
------------------------------

[](#priorities-and-execution-order)

- Lower priority numbers run first (5 runs before 10).
- Callbacks with the same priority run in the order they were added.

Using Facades
-------------

[](#using-facades)

If you prefer Facades over helper functions, use the provided `Action` and `Filter` Facades.

```
use ArtisanPackUI\Hooks\Facades\Action;
use ArtisanPackUI\Hooks\Facades\Filter;

Action::add('user.registered', fn ($user) => \Log::info('Registered: '.$user->id));
Action::do('user.registered', $user);

Filter::add('content.summary', fn ($text) => str($text)->limit(120));
$summary = Filter::apply('content.summary', $text);
```

Blade directives
----------------

[](#blade-directives)

You can trigger actions and apply filters directly within Blade views.

```
{{-- Trigger an action --}}
@action('view.rendering', $post)

{{-- Apply a filter and echo the result --}}
@filter('title.display', $post->title)
```

- `@action('hook', $args...)` calls `doAction('hook', $args...)`.
- `@filter('hook', $value, $args...)` echoes `applyFilters('hook', $value, $args...)`.

Testing locally
---------------

[](#testing-locally)

This repository uses Pest. Run the test suite with:

```
composer test
```

Contributing
------------

[](#contributing)

As an open source project, this package welcomes contributions. Please read the [contributing guidelines](CONTRIBUTING.md) before submitting issues or pull requests.

Security
--------

[](#security)

If you discover a security vulnerability, please review the Security section in the contributing guidelines and contact the maintainer directly. Do not open a public issue for security reports.

Changelog
---------

[](#changelog)

See [CHANGELOG.md](CHANGELOG.md) for a history of notable changes.

License
-------

[](#license)

This package is open-sourced software licensed under the [MIT license](LICENSE).

###  Health Score

48

—

FairBetter than 93% of packages

Maintenance94

Actively maintained with recent releases

Popularity21

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity52

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~78 days

Total

4

Last Release

26d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/ba2a2c40c9a93470595cd10701d2291434f3a7db61862d9700a9e69e31608c6c?d=identicon)[JacobMartellaWebDesign](/maintainers/JacobMartellaWebDesign)

---

Top Contributors

[![ViewFromTheBox](https://avatars.githubusercontent.com/u/8247489?v=4)](https://github.com/ViewFromTheBox "ViewFromTheBox (21 commits)")

---

Tags

actionseventsfiltershookslaravellaravel-packagephpwordpress-style

###  Code Quality

TestsPest

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/artisanpack-ui-hooks/health.svg)

```
[![Health](https://phpackages.com/badges/artisanpack-ui-hooks/health.svg)](https://phpackages.com/packages/artisanpack-ui-hooks)
```

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3355.3M346](/packages/psalm-plugin-laravel)[renatomarinho/laravel-page-speed

Laravel Page Speed

2.5k1.7M10](/packages/renatomarinho-laravel-page-speed)[illuminate/pagination

The Illuminate Pagination package.

12234.1M1.0k](/packages/illuminate-pagination)[illuminate/pipeline

The Illuminate Pipeline package.

9349.2M282](/packages/illuminate-pipeline)[illuminate/redis

The Illuminate Redis package.

8314.6M375](/packages/illuminate-redis)[illuminate/cookie

The Illuminate Cookie package.

244.6M137](/packages/illuminate-cookie)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
