PHPackages                             limen/redenvelope - 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. limen/redenvelope

ActiveLibrary

limen/redenvelope
=================

PHP library for red envelopes which are popular among Chinese

v0.1.5(9y ago)4642MITPHPPHP &gt;=5.4

Since Mar 3Pushed 7y agoCompare

[ Source](https://github.com/limen/redenvelope)[ Packagist](https://packagist.org/packages/limen/redenvelope)[ Docs](https://github.com/limen/redenvelope)[ RSS](/packages/limen-redenvelope/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (6)Dependencies (2)Versions (7)Used By (0)

PHP library for red envelope (红包) what is popular among Chinese.
================================================================

[](#php-library-for-red-envelope-红包-what-is-popular-among-chinese)

[![Build Status](https://camo.githubusercontent.com/5b383979a77e8549c60acc3469afa9ec26e4fb2b22e3507bebbba75debdea071/68747470733a2f2f7472617669732d63692e6f72672f6c696d656e2f726564656e76656c6f70652e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/limen/redenvelope)[![Packagist](https://camo.githubusercontent.com/65a2108e6eefed2accfdf3b68e11b7a20c16e6d57e180560a4755122c0b4d05f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6c696d656e2f726564656e76656c6f70652e7376673f6d61784167653d32353932303030)](https://packagist.org/packages/limen/redenvelope)

Features
--------

[](#features)

- Amount is assigned randomly.
- Minimum value of each assignment is settable.
- Amount precision is settable.
- Variance factor is settable which would influence the variance of the assignment sequence.

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

[](#installation)

Recommend to install via [composer](https://getcomposer.org/).

```
composer require "limen/redenvelope"
```

Usage
-----

[](#usage)

```
use Limen\RedEnvelope\Envelope;

$id = '123';                    // unique id
$remain = 212.23;               // envelope remain amount
$dividend = 10;                 // how many fragments to divide amount into
$minAssignment = 10.1;          // minimum value of each assignment
$precision = 2;                 // assignment precision

$varianceFactor = 1.0;          // Appropriate value should between 0.5 and 1.5, 1.0 may be the best.
                                // The greater this value, the greater the variance of the divided sequence is.

$envelope = new Envelope($id);

$envelope->setRemain($remain)
    ->setDividend($dividend);
    ->setPrecision($precision)
    ->setMinAssignment($minAssignment)
    ->setVarianceFactor($varianceFactor);

$assignment = $envelope->open();
```

Development
-----------

[](#development)

### Test

[](#test)

```
$ phpunit --bootstrap tests/bootstrap.php tests/
PHPUnit 5.7.15 by Sebastian Bergmann and contributors.

..
Total amount: 214.4
Dividend: 20
Minimum Assignment: 0.86
Variance factor: 0.7
Precision: 2
Assignment value: 10.72
..
Total amount: 64
Dividend: 4
Minimum Assignment: 7
Variance factor: 1.5
Precision: 0
Assignments:
No.0: 19.000000
No.1: 15.000000
No.2: 7.000000
No.3: 23.000000
.                                                               5 / 5 (100%)

Time: 165 ms, Memory: 13.25MB

OK (5 tests, 36 assertions)
```

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity52

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

Total

6

Last Release

3327d ago

PHP version history (3 changes)0.1.0PHP &gt;=5.6

v0.1.3PHP &gt;=5.5

v0.1.4PHP &gt;=5.4

### Community

Maintainers

![](https://www.gravatar.com/avatar/49d0b6c3647be78ab9b2703cd07c681a8098a0815f2ac676da4e3eafd2c08474?d=identicon)[limen](/maintainers/limen)

---

Top Contributors

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

---

Tags

assignmentrandomredenveloperedpacketvarianceredenvelope

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/limen-redenvelope/health.svg)

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

###  Alternatives

[ssnepenthe/color-utils

A PHP library for performing SASS-like color manipulations.

631.1M10](/packages/ssnepenthe-color-utils)

PHPackages © 2026

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