PHPackages                             pikart/laravel-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. pikart/laravel-hooks

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

pikart/laravel-hooks
====================

Simple hooks system for laravel

v0.1.0(7y ago)517MITPHPPHP &gt;=7.2

Since Nov 26Pushed 7y ago1 watchersCompare

[ Source](https://github.com/styryl/laravel-hooks)[ Packagist](https://packagist.org/packages/pikart/laravel-hooks)[ RSS](/packages/pikart-laravel-hooks/feed)WikiDiscussions master Synced 2d ago

READMEChangelogDependencies (3)Versions (2)Used By (0)

Installation
============

[](#installation)

Requirements:

php &gt;= 7.2
laravel &gt;= 5.7

Require this package with composer.

```
composer require pikart/laravel-hooks
```

This package will automatically register service provider and alias using laravel auto discovery functionality.

Copy the package config to your local config with the publish command:

```
php artisan vendor:publish --provider="Pikart\LaravelHooks\HookServiceProvider"
```

Usage
=====

[](#usage)

**Registering hooks**

Register method takes three parameters:

1. contract (**string**) required
    custom string or existing interface name
2. hook (**string**|**Closure**|**Pikart\\LaravelHook\\Contracts\\Hook**) required

    If contract is an existing interface, hook must be existing class name or class instance.
    The registered class must implement two interfaces. The interface to which it relates and
    the hooks interface (Pikart\\LaravelHook\\Contracts\\Hook).

    If hook is an existing class name, class will be resolved using laravel service container,
    so its may use auto instance injection in constructor.
3. priority (**int**) default 0
    Ordering execution of registered hooks, bigger will be execute first.

Register closure

```
HookManager::register('hook_name', function( array $args ) {
    return 'Hello world';
}, 10);
```

Register class

```
HookManager::register('hook_name', SomeHookClass::class, 10);
```

Register instance

```
HookManager::register('hook_name', new SomeHookClass::class, 10);
```

Register interface to implementation

```
HookManager::register(SomeHookInterface::class, SomeHookClass::class, 10);
```

**Executing**

Hooks are executing by hook method. Hook method takes two parameters:

1. Hook name (**string**) required
    custom string or existing interface name
2. Arguments (**array**)
3. Method (**string**)

Arguments are passed for execution and in the case of an existing class name to
create its instance using the laravel service container

Execute hook by custom name

```
$output = HookManager::hook('hook_name');
```

Execute hook by custom name with arguments

```
$user = User::find(1);

$output = HookManager::hook('hook_name', [
 'user' => $user]);
```

Execute hook by interface

```
$output = HookManager::hook(SomeHookInterface::class);
```

Execute hook by interface name with arguments

```
$user = User::find(1);

$output = HookManager::hook(SomeHookInterface::class, [
 'user' => $user]);
```

Execute hook by interface name with arguments and custom method

```
$user = User::find(1);

$output = HookManager::hook(SomeHookInterface::class, [
 'user' => $user], 'someMethod');
```

**Gets hooks to be executed**

Get method takes three parameters:

1. Hook name (**string**) required custom string or existing interface name
2. Argumesnts (**array**)

The get method works the same as the hook method, however, the hooks are not executed, array is returned.

Get prepared hooks

```
$hooks = HookManager::get(SomeHookInterface::class);
```

Get prepared hooks with arguments

```
$hooks = HookManager::get(SomeHookInterface::class, [
    'user' => $user
]);
```

**Gets raw hooks**

```
$hooks = HookManager::getRaw(SomeHookInterface::class);
```

**Tests**

```
 vendor/bin/phpunit --testdox
```

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity46

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

Unknown

Total

1

Last Release

2726d ago

### Community

Maintainers

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

---

Top Contributors

[![styryl](https://avatars.githubusercontent.com/u/1575669?v=4)](https://github.com/styryl "styryl (1 commits)")

---

Tags

laravelhooks

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/pikart-laravel-hooks/health.svg)

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

###  Alternatives

[livewire/volt

An elegantly crafted functional API for Laravel Livewire.

4195.3M84](/packages/livewire-volt)[gehrisandro/tailwind-merge-laravel

TailwindMerge for Laravel merges multiple Tailwind CSS classes by automatically resolving conflicts between them

341682.2k18](/packages/gehrisandro-tailwind-merge-laravel)[nickurt/laravel-akismet

Akismet for Laravel 11.x/12.x/13.x

97139.6k2](/packages/nickurt-laravel-akismet)[whitecube/laravel-timezones

Store UTC dates in the database and work with custom timezones in the application.

106106.2k](/packages/whitecube-laravel-timezones)[forxer/laravel-gravatar

A library providing easy gravatar integration in a Laravel project.

4235.6k](/packages/forxer-laravel-gravatar)[iteks/laravel-enum

A comprehensive Laravel package providing enhanced enum functionalities, including attribute handling, select array conversions, and fluent facade interactions for robust enum management in Laravel applications.

2516.7k](/packages/iteks-laravel-enum)

PHPackages © 2026

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