PHPackages                             soroushrah/action - 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. soroushrah/action

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

soroushrah/action
=================

Action and Event like Wordpress Hooks

43.7kPHP

Since Jun 13Pushed 4y ago1 watchersCompare

[ Source](https://github.com/soroushrah/Hook)[ Packagist](https://packagist.org/packages/soroushrah/action)[ RSS](/packages/soroushrah-action/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

 [![eventy logo](/art/logo.png)](/art/logo.png)

Hook in Laravel

About
-----

[](#about)

Actions are pieces of code you want to execute at certain points in your code.

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

[](#installation)

1. Install using Composer

```
composer require soroushrah/action

```

2. Add the service provider to the providers array in your `config/app.php`.

```
    Soroush\Action\ActionServiceProvider::class,
    Soroush\Action\ActionBladeServiceProvider::class,
```

3. Add the facade in `config/app.php`

```
    'Action' => \Soroush\Action\Facades\Action::class,
```

Usage
-----

[](#usage)

### Actions

[](#actions)

Anywhere in your code you can create a new action like so:

```
\Action::action('my.hook', 'soroush');
```

The first parameter is the name of the hook And Everything You pass after is argument.

To listen to your hooks, you attach listeners. These are best added to your `AppServiceProvider` `boot()` method.

For example if you wanted to hook in to the above hook, you could do:

```
\Action::addAction('my.hook', function($what) {
    echo 'Hello '. $what;
}, 20, 1);

```

Again the first argument must be the name of the hook. second would be a callback. Third is Priority. Fourth is number of arguments would accepted.(default is 1)

### Using in Blade

[](#using-in-blade)

Adding the same action as the one in the action example above:

```
@action('my.hook', 'awesome')

```

### Add Daynamic Relation Models

[](#add-daynamic-relation-models)

For add some relation on models are not in your module you should use HasDynamicRelation trait in your all project model :

```
class MyModel extends Model {
    use HasDynamicRelation;
}

```

Then add dynamic relation like example above on providers :

```
MyModel::addDynamicRelation('some_relation', function(MyModel $model) {
    return $model->hasMany(SomeRelatedModel::class);
});

```

Credits
-------

[](#credits)

- Created by Soroush Rahmani

###  Health Score

21

—

LowBetter than 19% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity21

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity29

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://www.gravatar.com/avatar/bd41ff1d93e386c1f513cd6814bbe4533e9acdc7b666fda7415a79deabc20ed9?d=identicon)[soroush](/maintainers/soroush)

---

Top Contributors

[![soroushrah](https://avatars.githubusercontent.com/u/23644872?v=4)](https://github.com/soroushrah "soroushrah (11 commits)")

### Embed Badge

![Health badge](/badges/soroushrah-action/health.svg)

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

PHPackages © 2026

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