PHPackages                             mhndev/event - 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. mhndev/event

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

mhndev/event
============

1.2.2(8y ago)52962MITPHPPHP &gt;=5.3.9

Since Jul 9Pushed 8y ago2 watchersCompare

[ Source](https://github.com/mhndev/event)[ Packagist](https://packagist.org/packages/mhndev/event)[ RSS](/packages/mhndev-event/feed)WikiDiscussions develop Synced 2mo ago

READMEChangelogDependenciesVersions (9)Used By (0)

About
-----

[](#about)

This is a really simple and lightweight php package for developing event based software

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

[](#installation)

```
composer require mhndev/event

```

Sample Usage
------------

[](#sample-usage)

### bind an closure to an event

[](#bind-an-closure-to-an-event)

```
Event::bind('order.payed',function($order){
    //do some cool stuf here
});
```

### Another example

[](#another-example)

```
class MyClass {
    public function __invoke($order) {
        //do something here
    }
}

$myObject = new MyClass;

Event::bind('order.payed', $myObject($order));
```

### trigger an event

[](#trigger-an-event)

```
// pass $order object as second argument
Event::trigger('order.payed', $order);
```

### Entity ( Model ) Observer

[](#entity--model--observer)

Binding an observer for a specific event on a model.

```
User::addObserver('before_update', function($driver){

});
```

Firing an Event on a model object.

Active Record Pattern

```
class User
{
    use \mhndev\event\ObservableTrait;

    function update(array $data)
    {
        $user = $this;

        $this->fireEvent('before_update', $this);

        $updatedUser = $this->update($array);

        $driver->fireEvent('after_update', $user, $updatedUser);
    }
}
```

Data Mapper Pattern

```
class User
{
    use \mhndev\event\ObservableTrait;
}

class UserRepository
{

    function update($user_identifier, array $data)
    {
        $user = $this->findByIdentifier($user_identifier);

        $user->buildByOptions($data);

        $user->fireEvent('before_update', $user);

        $updatedUser = $this->update($user);

        $driver->fireEvent('after_update', $user, $updatedUser);

        return $updatedUser;
    }
}
```

Todos
-----

[](#todos)

-implement tests

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity18

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor1

Top contributor holds 85.7% 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 ~75 days

Total

7

Last Release

3146d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/5c3e5d182214e2e6b989a2230bcae80b2107b088da1c6dbea6f6f8d28702e272?d=identicon)[majidphpdeveloper](/maintainers/majidphpdeveloper)

---

Top Contributors

[![mhndev](https://avatars.githubusercontent.com/u/5164182?v=4)](https://github.com/mhndev "mhndev (6 commits)")[![majidakbari](https://avatars.githubusercontent.com/u/17963906?v=4)](https://github.com/majidakbari "majidakbari (1 commits)")

---

Tags

eventevent-managementevent-systemphpeventphp-eventevent basedevent orientedtrigger eventbind event

### Embed Badge

![Health badge](/badges/mhndev-event/health.svg)

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

PHPackages © 2026

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