PHPackages                             princebo/library - 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. princebo/library

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

princebo/library
================

收集整理常用的php工具类库 Some of the PHP class libraries in the collection

v1.0(5y ago)076MITPHPPHP &gt;=7.1CI failing

Since May 28Pushed 5y ago1 watchersCompare

[ Source](https://github.com/bogegithub/class-library)[ Packagist](https://packagist.org/packages/princebo/library)[ RSS](/packages/princebo-library/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (1)Versions (2)Used By (0)

class-library
=============

[](#class-library)

常用类库收集

使用
==

[](#使用)

`composer require princebo/library`

Snowflake.php
-------------

[](#snowflakephp)

> 基于Twitter的雪花算法改造，分布式全局唯一ID生成器, 组成&lt;毫秒级时间戳+机器ip+进程id+序列号&gt;

长度最长为64位bit,各bit位含义如下：

- `1位` 不用。二进制中最高位为1的都是负数，但是我们生成的id一般都使用整数，所以这个最高位固定是0
- `41位` 用来记录时间戳（毫秒）
    - 41位可以表示$2^{41}-1$个数字，
    - 如果只用来表示正整数（计算机中正数包含0），可以表示的数值范围是：0 至 $2^{41}-1$，减1是因为可表示的数值范围是从0开始算的，而不是1。
    - 也就是说41位可以表示$2^{41}-1$个毫秒的值，转化成单位年则是$(2^{41}-1) / (1000 \* 60 \* 60 \* 24 \* 365) = 69$年
- `10位` 机器IP低10位,可以支持最多1023个机器节点
- `10位` 当前处理进程标识,10位的长度最多支持1023个机器进程
- `2位` 计数序列号,序列号即序列自增id,可以支持同一节点的同一进程同一毫秒生成4个ID序号

```
use Princebo\Library\Snowflake;

//生成一个全局唯一ID
echo Snowflake::uniqueId();
```

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity50

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

Unknown

Total

1

Last Release

2180d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/23090283?v=4)[bogegithub](/maintainers/bogegithub)[@bogegithub](https://github.com/bogegithub)

---

Top Contributors

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

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/princebo-library/health.svg)

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

PHPackages © 2026

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