PHPackages                             zicai/hongbao - 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. zicai/hongbao

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

zicai/hongbao
=============

Generate fixed red package and random red package, random red envelopes based on truncated normal distribution algorithm to generate

V1.1.2(6y ago)233168MITPHPPHP &gt;=7.0.0CI failing

Since Jan 31Pushed 6y ago2 watchersCompare

[ Source](https://github.com/pmw1014/hongbao)[ Packagist](https://packagist.org/packages/zicai/hongbao)[ RSS](/packages/zicai-hongbao/feed)WikiDiscussions master Synced yesterday

READMEChangelog (4)Dependencies (1)Versions (12)Used By (0)

红包生成器
=====

[](#红包生成器)

生成固定红包与随机红包，随机红包金额依据截尾正态分布算法来生成

> Generate fixed red package and random red package, random red envelopes based on truncated normal distribution algorithm to generate

### Composer 安装

[](#composer-安装)

composer require zicai/hongbao

[![图像画案例](https://camo.githubusercontent.com/46d8fd25482ec665d357e41ce2ea9d6b5330b48c73e93bdaac7eaf6b7db26e3d/687474703a2f2f7a696361692e66756e2f696d616765732f313631653065383531356462346134332e676966)](https://camo.githubusercontent.com/46d8fd25482ec665d357e41ce2ea9d6b5330b48c73e93bdaac7eaf6b7db26e3d/687474703a2f2f7a696361692e66756e2f696d616765732f313631653065383531356462346134332e676966)

### 生成随机红包(Random Red Package)

[](#生成随机红包random-red-package)

```
require_once '../vendor/autoload.php';

use Hongbao\Hongbao;

/**
 * 生成随机红包
 */
$options = [
    'total_money' => 1000, // 总金额
    'total_number' => 1000, // 总红包数量
    'minimum_val' => 0.01, // 最小随机红包金额
    'maximum_val' => 20, // 最大随机红包金额
];

//通过try catch获取可能出现的参数设置错误信息
try {
    $hongbao = Hongbao::getInstance()->randomAmount($options);
    foreach ($hongbao as $result) {
        echo "";
        print_r($result);
    }
} catch (\Exception $e) {
    $error = $e->getMessage();
    var_dump($error);
}
```

### 生成固定红包(fixed red package)

[](#生成固定红包fixed-red-package)

```
require_once '../vendor/autoload.php';

use Hongbao\Hongbao;

/**
 * 生成固定红包
 */

$options = [
    'total_money' => 1000, // 总金额
    'total_number' => 1000, // 总红包数量
    'val' => 0.01, // 单个红包金额
];

//通过try catch获取可能出现的参数设置错误信息
try {
    $hongbao = Hongbao::getInstance()->fixedAmount($options);
    foreach ($hongbao as $result) {
        echo "";
        print_r($result);
    }
} catch (\Exception $e) {
    $error = $e->getMessage();
    var_dump($error);
}
```

###  Health Score

33

—

LowBetter than 75% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity23

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity65

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

Recently: every ~2 days

Total

11

Last Release

2196d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/4e2c677cdd6bded9ea57a5c54dcf5390efec39755322372094a61c79af292d9d?d=identicon)[pmw1014](/maintainers/pmw1014)

---

Top Contributors

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

---

Tags

hongbao

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/zicai-hongbao/health.svg)

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

###  Alternatives

[astrotomic/laravel-unavatar

Laravel integration of unavatar service.

297.9k](/packages/astrotomic-laravel-unavatar)[tatter/workflows

Job task control through dynamic workflows, for CodeIgniter 4

221.6k](/packages/tatter-workflows)

PHPackages © 2026

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