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

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

friendsofhyperf/once
====================

A magic memoization function for Hyperf.

v3.1.1(2y ago)36MITPHP

Since Mar 24Pushed 2y ago1 watchersCompare

[ Source](https://github.com/friendsofhyperf/once)[ Packagist](https://packagist.org/packages/friendsofhyperf/once)[ RSS](/packages/friendsofhyperf-once/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (3)Versions (29)Used By (0)

Once
====

[](#once)

[![Latest Stable Version](https://camo.githubusercontent.com/3bc55f677e2efb786565766afceaf864106a2b397e5000feb5973a9d45104758/68747470733a2f2f706f7365722e707567782e6f72672f667269656e64736f666879706572662f6f6e63652f76657273696f6e2e706e67)](https://packagist.org/packages/friendsofhyperf/once)[![Total Downloads](https://camo.githubusercontent.com/61f5328068a682286343af33048fa7431dbd1b6d37842d4443bc8101b7143847/68747470733a2f2f706f7365722e707567782e6f72672f667269656e64736f666879706572662f6f6e63652f642f746f74616c2e706e67)](https://packagist.org/packages/friendsofhyperf/once)[![GitHub license](https://camo.githubusercontent.com/a90ebc7d3230d06648117d8dbc97a3775fb8ad8006166fd7b53df56342b27ce4/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f667269656e64736f666879706572662f6f6e6365)](https://github.com/friendsofhyperf/once)

A magic memoization function for Hyperf.

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

[](#installation)

- Installation

```
composer require friendsofhyperf/once
```

Documentation
-------------

[](#documentation)

- [Documentation](https://github.com/spatie/once)

Usage
-----

[](#usage)

```
use FriendsOfHyperf\Once\Annotation\Forget;
use FriendsOfHyperf\Once\Annotation\Once;

class Foo
{
    #[Once]
    public function getNumber(): int
    {
        return rand(1, 10000);
    }

    #[Forget]
    public function forgetNumber()
    {
    }
}
```

Donate
------

[](#donate)

> If you like them, Buy me a cup of coffee. [Alipay](https://hdj.me/images/alipay-min.jpg) | [WeChat](https://hdj.me/images/wechat-pay-min.jpg)

Contact
-------

[](#contact)

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

License
-------

[](#license)

[MIT](LICENSE)

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community7

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

Total

28

Last Release

896d ago

Major Versions

1.0.0 → 2.0.02022-03-24

v1.0.3 → v2.0.12022-08-16

v2.0.2-beta.1 → v3.0.12023-01-04

### 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 (19 commits)")

---

Tags

hyperfv3.1

### Embed Badge

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

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

###  Alternatives

[hyperf/crontab

A crontab component for Hyperf.

131.6M62](/packages/hyperf-crontab)[hyperf/watcher

Hot reload watcher for Hyperf

17846.7k27](/packages/hyperf-watcher)[hyperf/socketio-server

Socket.io implementation for hyperf

25130.9k6](/packages/hyperf-socketio-server)[friendsofhyperf/sentry

The sentry component for Hyperf.

1864.6k](/packages/friendsofhyperf-sentry)

PHPackages © 2026

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