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

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

mitoop/snowflake
================

snowflake

v1.0.1(2y ago)0279[1 issues](https://github.com/mitoop/snowflake/issues)1MITPHPPHP &gt;=7.0

Since Sep 23Pushed 2y ago1 watchersCompare

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

READMEChangelogDependencies (1)Versions (3)Used By (1)

Snowflake 雪花算法
==============

[](#snowflake-雪花算法)

说明
--

[](#说明)

雪花算法(64bits)的 PHP 实现

要求
--

[](#要求)

1. PHP &gt;= 7.0

安装
--

[](#安装)

```
$ composer require mitoop/snowflake
```

使用
--

[](#使用)

```
use Mitoop\Snowflake\Snowflake;

// 初始化
$snowflake = new Snowflake('2020-10-24 10:24:00');
// 设置数据中心ID及机器ID(范围: 0-31)，默认用随机数
$snowflake->setDatacenterId(1);
$snowflake->setWorkerId(1);
// 设置生成序列号策略 不设置默认就是用的随机数策略
$snowflake->setSequenceStrategy(new RandomSequenceStrategy());
// here we go
$snowflake->id();
```

Tips
----

[](#tips)

雪花 id 长度`[7-19]`位，实践中，选择合适的纪元时间，使生成的雪花 id 从指定长度开始

###  Health Score

23

—

LowBetter than 26% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity43

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

Total

2

Last Release

864d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/1645a978f51dcbbc8e50a17bf7daaa12fd1b01a4b19784d0010325d78c9b53f8?d=identicon)[Mitoop](/maintainers/Mitoop)

---

Top Contributors

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

---

Tags

snowflake

###  Code Quality

Code StyleLaravel Pint

### Embed Badge

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

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

###  Alternatives

[kyslik/column-sortable

Package for handling column sorting in Laravel 6.x

6625.9M26](/packages/kyslik-column-sortable)[symfony/polyfill-php55

Symfony polyfill backporting some PHP 5.5+ features to lower PHP versions

10732.0M9](/packages/symfony-polyfill-php55)[php-units-of-measure/php-units-of-measure

A PHP library for converting between standard units of measure.

3143.8M35](/packages/php-units-of-measure-php-units-of-measure)[rundiz/thai-date

Display date in Thai language use PHP date() and strftime()

167.8k](/packages/rundiz-thai-date)

PHPackages © 2026

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