PHPackages                             mprince/larahooks - 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. mprince/larahooks

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

mprince/larahooks
=================

laravel hook system for binding any service in a action and filter

08PHP

Since Mar 7Pushed 5y ago1 watchersCompare

[ Source](https://github.com/mprince2k18/larahooks)[ Packagist](https://packagist.org/packages/mprince/larahooks)[ RSS](/packages/mprince-larahooks/feed)WikiDiscussions main Synced 5d ago

READMEChangelogDependenciesVersions (1)Used By (0)

[![Latest Stable Version](https://camo.githubusercontent.com/e170ac4ec372dec3679b5838aca88e64ad209a35e8156fec427488ce4f8ea62c/68747470733a2f2f706f7365722e707567782e6f72672f6d7072696e63652f6c617261686f6f6b732f762f737461626c65)](https://packagist.org/packages/mprince/larahooks)[![Total Downloads](https://camo.githubusercontent.com/ec110119e79f26628e0eccc8596ab94bde5d6d799e72073da7136cf38a29a33d/68747470733a2f2f706f7365722e707567782e6f72672f6d7072696e63652f6c617261686f6f6b732f646f776e6c6f616473)](https://packagist.org/packages/mprince/larahooks)[![Latest Unstable Version](https://camo.githubusercontent.com/781c3976fef9797809f696f95f1347b78fadf741eb976e8fa6cec3ced1b5e45a/68747470733a2f2f706f7365722e707567782e6f72672f6d7072696e63652f6c617261686f6f6b732f762f756e737461626c65)](https://packagist.org/packages/mprince/larahooks)[![License](https://camo.githubusercontent.com/7cf51611d222ad63a00eb11f38e0f7deda896d3a137e22d38b7d63f4b6c5c06d/68747470733a2f2f706f7365722e707567782e6f72672f6d7072696e63652f6c617261686f6f6b732f6c6963656e7365)](https://packagist.org/packages/mprince/larahooks)

Larahooks
=========

[](#larahooks)

A Laravel 8 package for action and filter hook. Its helps to you fire any event with your desire action. Its a similar service as WP action and filter.

Inspired from [nahid](https://github.com/nahid/hookr)

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

[](#installation)

Write these command from you terminal.

```
composer require mprince/larahooks
```

Thats all

Usages
------

[](#usages)

Its so easy to use. Just follow the instruction and apply with your laravel project.

### Action

[](#action)

You want to extra control with your application without touching your code you apply Action. Suppose you have a blog editor panel. Where you want add extra buttons from others developer without rewrite your code. so lets see.

```

        Title

        Blog

    Publish
    {{do_action('buttons')}}

```

[![Demo](https://camo.githubusercontent.com/88af22a780657e0a9ee67a39523cb3237cf192e6c0c84519402e41185149fe98/687474703a2f2f692e696d6775722e636f6d2f78714e316272712e706e67 "demo")](https://camo.githubusercontent.com/88af22a780657e0a9ee67a39523cb3237cf192e6c0c84519402e41185149fe98/687474703a2f2f692e696d6775722e636f6d2f78714e316272712e706e67)

See, here we use `do_action()` helper function which is register as named `buttons`So if others developer is want to add more buttons with this form they will do this

```
use Mprince\Larahooks\Facades\Hook;

class BlogController extends Controller
{
      public function getWritePost()
      {
          hook()->bindAction('buttons', function() {
              echo ' Draft';
          }, 2);

          return view('post');
     }
}
```

After run this code add new button will add with existing button.

[![Demo](https://camo.githubusercontent.com/68ef627de058bd31f167741cb5b8cb837948a6af306e7778fdcc6fae1f79f7c7/687474703a2f2f692e696d6775722e636f6d2f55647931546b472e706e67 "demo")](https://camo.githubusercontent.com/68ef627de058bd31f167741cb5b8cb837948a6af306e7778fdcc6fae1f79f7c7/687474703a2f2f692e696d6775722e636f6d2f55647931546b472e706e67)

You can also bind multiple action with this hook. LaraHooks also support filter. Remind this when you bind multiple filter in a hook then every filter get data from previous filters return data. Suppose you want to add a filter hook in a blog view section.

```
  {{$blog->title}}

  {{apply_filters('posts', $blog->content)}}

```

So we register a filter as 'posts'. Now another developer wants to support markdown for blog posts. so he can bind a filter for parse markdown.

```
 use Mprince\Larahooks\Facades\Hook;

 class BlogController extends Controller
 {
       public function getPosts()
       {
           hook()->bindFilter('posts', function($data) {
               return parse_markdown($data);
           }, 2);

           return view('post');
      }
 }
```

Note: In filter, every callback function must have at least one param which is represent current data

so if you want to bind multiple data then

```
  use Mprince\Larahooks\Facades\Hook;

  class BlogController extends Controller
  {
        public function getPosts()
        {
            hook()->bindFilter('posts', function($data) {
                return parse_markdown($data);
            }, 2);

            hook()->bindFilter('posts', function($data) {
                return parse_bbcode($data);
            }, 3);

            return view('post');
       }
  }
```

Now then given data is parse by markdown and bbcode. See, here is second param for `bindFilter()` is a priority for binding. Both `bindAction()` and `bindFilter()` has this feature.

Blade View
----------

[](#blade-view)

You can show a blade file through `bindAction()` and `bindFilter()`

```
  use Mprince\Larahooks\Facades\Hook;

  class BlogController extends Controller
  {
        public function index()
        {
            hook()->bindFilter('posts', function($data) {
                return view('index');
            }, 2);

            return view('post');
       }
  }
```

Compacting Data
---------------

[](#compacting-data)

```
  use Mprince\Larahooks\Facades\Hook;
  use App\Models\User;

  class BlogController extends Controller
  {
        public function index()
        {
            hook()->bindFilter('posts', function($data) {
                $user = User::all();
                return view('index', compact('user'));
            }, 1);

            return view('post');
       }
  }
```

###  Health Score

16

—

LowBetter than 5% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity30

Early-stage or recently created project

 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.

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/43857625?v=4)[Mohammad Prince](/maintainers/mprince2k18)[@mprince2k18](https://github.com/mprince2k18)

---

Top Contributors

[![mprince2k18](https://avatars.githubusercontent.com/u/43857625?v=4)](https://github.com/mprince2k18 "mprince2k18 (9 commits)")

### Embed Badge

![Health badge](/badges/mprince-larahooks/health.svg)

```
[![Health](https://phpackages.com/badges/mprince-larahooks/health.svg)](https://phpackages.com/packages/mprince-larahooks)
```

###  Alternatives

[ibrahimbougaoua/filament-rating-star

This is my package filament-rating-star

4295.6k1](/packages/ibrahimbougaoua-filament-rating-star)

PHPackages © 2026

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