PHPackages                             friendsofhyperf/model-observer - 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. friendsofhyperf/model-observer

ActiveLibrary

friendsofhyperf/model-observer
==============================

The model observer component for Hyperf.

v3.1.75(3mo ago)12.7k↓100%MITPHP

Since May 21Pushed 3mo ago1 watchersCompare

[ Source](https://github.com/friendsofhyperf/model-observer)[ Packagist](https://packagist.org/packages/friendsofhyperf/model-observer)[ Fund](https://hdj.me/sponsors/)[ GitHub Sponsors](https://github.com/huangdijia)[ RSS](/packages/friendsofhyperf-model-observer/feed)WikiDiscussions main Synced today

READMEChangelog (10)Dependencies (6)Versions (104)Used By (0)

model-observer
==============

[](#model-observer)

[![Latest Stable Version](https://camo.githubusercontent.com/a33cf70588b5ed549f0cc03d17d4276263dde6dcee22626dbf9553adecc48641/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f667269656e64736f666879706572662f6d6f64656c2d6f62736572766572)](https://packagist.org/packages/friendsofhyperf/model-observer)[![Total Downloads](https://camo.githubusercontent.com/823cbdb8e299381ee7c4eb6d858503a6a257cb14d5a246c8f4d7635be8e62c60/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f667269656e64736f666879706572662f6d6f64656c2d6f62736572766572)](https://packagist.org/packages/friendsofhyperf/model-observer)[![License](https://camo.githubusercontent.com/5f9244b9854a822f4a9dae26133d1b7c2afb9ff72001f033c1b4e3c5b60d909e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f667269656e64736f666879706572662f6d6f64656c2d6f62736572766572)](https://github.com/friendsofhyperf/model-observer)

The model observer component for Hyperf.

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

[](#installation)

```
composer require friendsofhyperf/model-observer
```

Usage
-----

[](#usage)

- Generator command

```
php bin/hyperf.php gen:observer TestObserver --model="App\\Model\\User"
```

- Single binding

```
namespace App\Observer;

use App\Model\User;
use FriendsOfHyperf\ModelObserver\Annotation\Observer;

#[Observer(model: User::class)]
class FooObserver
{
    public function creating(User $model)
    {
        // do sth...
    }

    public function created(User $model)
    {
        // do sth...
    }

    // another events
}
```

- Multiple binding

```
namespace App\Observer;

use App\Model\Post;
use App\Model\User;
use FriendsOfHyperf\ModelObserver\Annotation\Observer;

#[Observer(model: [User::class, Post::class])]
class FooObserver
{
    public function creating($model)
    {
        // do sth...
    }

    public function created($model)
    {
        // do sth...
    }

    // another events
}
```

- Binding on model

```
namespace App\Model;

use App\Observer\FooObserver;

#[ObservedBy(FooObserver::class)]
class User extends Model
{
    // ...
}
```

Methods
-------

[](#methods)

- `booting`
- `booted`
- `retrieved`
- `creating`
- `created`
- `updating`
- `updated`
- `saving`
- `saved`
- `restoring`
- `restored`
- `deleting`
- `deleted`
- `forceDeleted`

Contact
-------

[](#contact)

- [Twitter](https://twitter.com/huangdijia)
- [Gmail](mailto:huangdijia@gmail.com)

License
-------

[](#license)

[MIT](LICENSE)

###  Health Score

46

—

FairBetter than 93% of packages

Maintenance79

Regular maintenance activity

Popularity19

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity64

Established project with proven stability

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

Recently: every ~74 days

Total

103

Last Release

115d ago

Major Versions

v2.0.13 → v3.0.0-beta292022-06-24

v2.0.16 → v3.0.0-rc.12022-08-10

v2.0.19 → v3.0.0-rc.162022-09-21

v2.0.24 → v3.0.0-rc.402022-12-02

v2.0.28 → v3.0.142023-02-10

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/8337659?v=4)[Deeka Wong](/maintainers/huangdijia)[@huangdijia](https://github.com/huangdijia)

---

Top Contributors

[![huangdijia](https://avatars.githubusercontent.com/u/8337659?v=4)](https://github.com/huangdijia "huangdijia (66 commits)")

---

Tags

hyperfv3.1

### Embed Badge

![Health badge](/badges/friendsofhyperf-model-observer/health.svg)

```
[![Health](https://phpackages.com/badges/friendsofhyperf-model-observer/health.svg)](https://phpackages.com/packages/friendsofhyperf-model-observer)
```

###  Alternatives

[mineadmin/mineadmin

Quickly build a background management system for web applications

1.2k2.0k](/packages/mineadmin-mineadmin)[friendsofhyperf/sentry

The sentry component for Hyperf.

1861.7k](/packages/friendsofhyperf-sentry)[hyperf/http-server

A HTTP Server for Hyperf.

102.8M272](/packages/hyperf-http-server)[friendsofhyperf/validated-dto

The Data Transfer Objects with validation for Hyperf.

1412.2k](/packages/friendsofhyperf-validated-dto)[friendsofhyperf/telescope

An elegant debug assistant for the hyperf framework.

224.8k2](/packages/friendsofhyperf-telescope)

PHPackages © 2026

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