PHPackages                             josephlavin/local-eventing - 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. josephlavin/local-eventing

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

josephlavin/local-eventing
==========================

In object eventing execution

1.0.1(9y ago)061MITPHPPHP 5.6.0

Since Aug 14Pushed 9y ago1 watchersCompare

[ Source](https://github.com/josephlavin/local-eventing)[ Packagist](https://packagist.org/packages/josephlavin/local-eventing)[ RSS](/packages/josephlavin-local-eventing/feed)WikiDiscussions master Synced today

READMEChangelog (2)Dependencies (2)Versions (3)Used By (0)

Local Eventing
==============

[](#local-eventing)

A simple php trait that allows for execution of local methods in an eventing like fashion. Add methods to a class using this trait following a naming convention and they will be executed when the local event is fired.

```
use josephlavin\localEventing\LocalEventing;

class dummy
{
    use LocalEventing;

    public function save()
    {
        // do your saving logic...
        $this->fireLocalEvent('saved');
    }

    protected function __onLocalEvent_saved_send_notification()
    {
        // Logic here to send notification...
    }

    protected function __onLocalEvent_saved_log_event()
    {
        // Logic for logging here...
    }
}
```

Event Listener Method Naming Convention
---------------------------------------

[](#event-listener-method-naming-convention)

All event listener methods must be named in this fashion: `__onLocalEvent_[event]_[description]()`

- `__onLocalEvent_` : namespace for the local eventing system
- `[event]`: the same string given to `$this->fireLocalEvent('event')`
- `[description]`: a simple description of what this method does

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

[](#installation)

```
$ composer require josephlavin/local-eventing

```

Use Case
--------

[](#use-case)

Lets say we have a basic model type class which fires local events:

```
class BaseModel
{
    use LocalEventing;

    public function __construct()
    {
        $this->fireLocalEvent('created');
    }

    public function insert()
    {
        $this->fireLocalEvent('preInsert');
        // the insert logic...
        $this->fireLocalEvent('postInsert');
    }
}
```

We can create another trait that relies on the LocalEventing trait and adds `__onLocalEvent__` methods. Notice how this trait has an abstract method `_require_trait_LocalEventing`. This serves as a reminder to the developer that this trait relies on the `LocalEventing` trait to work properly.

```
trait UuidPrimaryKey
{
    // reminder that we must also use LocalEventing Trait
    abstract protected function _require_trait_LocalEventing();

    protected function __onLocalEvent_preInsert_populate_uuid()
    {
        // generate and set a uuid primary key here...
    }
}
```

Now any models (that extend base model) can use the `UuidPrimaryKey` trait and gain that functionality.

```
class MyModel extends BaseModel
{
    use UuidPrimaryKey;
}
```

###  Health Score

25

—

LowBetter than 36% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity59

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 ~0 days

Total

2

Last Release

3606d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/7443997?v=4)[Joseph Lavin](/maintainers/josephlavin)[@josephlavin](https://github.com/josephlavin)

---

Top Contributors

[![josephlavin](https://avatars.githubusercontent.com/u/7443997?v=4)](https://github.com/josephlavin "josephlavin (6 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/josephlavin-local-eventing/health.svg)

```
[![Health](https://phpackages.com/badges/josephlavin-local-eventing/health.svg)](https://phpackages.com/packages/josephlavin-local-eventing)
```

###  Alternatives

[jofrysutanto/windsor

YAML-ised Configuration for ACF

549.2k](/packages/jofrysutanto-windsor)[jshannon63/jsoncollect

Supercharge your JSON using collections

155.0k1](/packages/jshannon63-jsoncollect)

PHPackages © 2026

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