PHPackages                             jisheng100/snowflake - 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. jisheng100/snowflake

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

jisheng100/snowflake
====================

Webman plugin jisheng100/snowflake

v1.0.3(5mo ago)6447MITPHP

Since Dec 6Pushed 5mo ago1 watchersCompare

[ Source](https://github.com/jisheng100/snowflake)[ Packagist](https://packagist.org/packages/jisheng100/snowflake)[ RSS](/packages/jisheng100-snowflake/feed)WikiDiscussions main Synced today

READMEChangelog (4)DependenciesVersions (5)Used By (0)

简介
--

[](#简介)

### Webman 雪花 ID 生成类

[](#webman-雪花-id-生成类)

使用简单、高效的雪花 ID 算法生成唯一的 64 位整数 ID，支持高并发场景，适合分布式系统中唯一标识的生成需求。

安装
--

[](#安装)

```
composer require jisheng100/snowflake

```

使用
--

[](#使用)

### 1. 生成雪花id

[](#1-生成雪花id)

```
$id =  \Jisheng100\Snowflake\Snowflake::instance()->generateId();

```

### 2. 解析雪花id

[](#2-解析雪花id)

```
$detail = \Jisheng100\Snowflake\Snowflake::instance()->parseId($id);

```

配置
--

[](#配置)

雪花 ID 算法基于 64 位整数设计，其中：

- 符号位：1 位，始终为 0，保证生成的 ID 为正数。
- 时间戳：41 位，表示毫秒级时间戳，足够支持约 69 年的时间跨度。
- 机器 ID + 进程 ID：共 10 位，用于标识唯一的机器和进程。
- 序列号：12 位，用于在同一毫秒内生成多个唯一 ID，支持每毫秒最多生成 4096 个 ID。

### 配置参数说明

[](#配置参数说明)

可以根据业务需求自定义以下参数，确保在高并发场景下生成唯一 ID：

```
return [
    'enable' => true,
    'machine_id' => 0,//机器id序号，多台机器需要更改这里
    'machine_id_bits' => 3, //机器id位数，值范围为0-7(2的3次方)
    'process_id_bits' => 7,//进程id位数，值范围为0-127(2的7次方)
    'sequence_bits' => 12, //序列号位数，每微秒可生成的数量4096
];

```

注意事项
----

[](#注意事项)

- **机器 ID 配置**：多台机器需确保 machine\_id 值唯一。
- **进程 ID 位数**：需大于等于实际业务所需的最大进程数。例如，如果业务使用了 64 个进程，则 process\_id\_bits 至少为 6 位。
- **序列号位数**：默认支持每毫秒生成 4096 个 ID，如需更高并发，可调整配置。

###  Health Score

38

—

LowBetter than 83% of packages

Maintenance73

Regular maintenance activity

Popularity21

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity42

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

Total

4

Last Release

152d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/771e873e6d4b26904caec229f670211e17243c86f90633477ea32a03a4ff2b7a?d=identicon)[jisheng100](/maintainers/jisheng100)

---

Top Contributors

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

### Embed Badge

![Health badge](/badges/jisheng100-snowflake/health.svg)

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

###  Alternatives

[jcergolj/extra-checks-for-spatie-laravel-server-monitor

Additional custom checks for Spatie laravel-server-monitor package

546.5k](/packages/jcergolj-extra-checks-for-spatie-laravel-server-monitor)[nextgen-tech/gs1-decoder

1030.0k](/packages/nextgen-tech-gs1-decoder)[rexlmanu/laravel-tickets

Simple but effective solutions to provide support

171.2k](/packages/rexlmanu-laravel-tickets)

PHPackages © 2026

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