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

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

zenphp/snowflake
================

An ID Generator for PHP based on Snowflake Algorithm (Twitter announced).

v3.3.0(3mo ago)04211MITPHPPHP ^8.4

Since Apr 19Pushed 3mo agoCompare

[ Source](https://github.com/zenphporg/snowflake)[ Packagist](https://packagist.org/packages/zenphp/snowflake)[ RSS](/packages/zenphp-snowflake/feed)WikiDiscussions 3.x Synced 2w ago

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

 [![](/.github/image/snowflake.png)](/.github/image/snowflake.png)

 An ID Generator for PHP based on Snowflake Algorithm (Twitter announced).

Snowflake
=========

[](#snowflake)

`zenphp/snowflake`

Description
-----------

[](#description)

Snowflake is a network service for generating unique ID numbers at high scale with some simple guarantees.

- The first bit is unused sign bit.
- The second part consists of a 41-bit timestamp (milliseconds) whose value is the offset of the current time relative to a certain time.
- The 5 bits of the third and fourth parts represent data center and worker, and max value is 2^5 -1 = 31.
- The last part consists of 12 bits, its means the length of the serial number generated per millisecond per working node, a maximum of 2^12 -1 = 4095 IDs can be generated in the same millisecond.
- In a distributed environment, five-bit datacenter and worker mean that can deploy 31 datacenters, and each datacenter can deploy up to 31 nodes.
- The binary length of 41 bits is at most 2^41 -1 millisecond = 69 years. So the snowflake algorithm can be used for up to 69 years, In order to maximize the use of the algorithm, you should specify a start time for it.

> You must know, The ID generated by the snowflake algorithm is not guaranteed to be unique. For example, when two different requests enter the same node of the same data center at the same time, and the sequence generated by the node is the same, the generated ID will be duplicated.

So if you want use the snowflake algorithm to generate unique ID, You must ensure: The sequence-number generated in the same millisecond of the same node is unique. Based on this, we created this package and integrated multiple sequence-number providers into it.

- RandomSequenceResolver (Random)
- RedisSequenceResolver (based on redis psetex and incrby)
- LaravelSequenceResolver (based on redis psetex and incrby)
- SwooleSequenceResolver (based on swoole\_lock)

> Each provider only needs to ensure that the serial number generated in the same millisecond is different. You can get a unique ID.

Requirement
-----------

[](#requirement)

1. PHP &gt;= 8.2
2. **[Composer](https://getcomposer.org/)**

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

[](#installation)

```
$ composer require zenphp/snowflake
```

Useage
------

[](#useage)

Coming soon ...

Advanced
--------

[](#advanced)

Coming soon ...

License
-------

[](#license)

MIT

Ported and enhanced from the [Godruoyi](https://github.com/godruoyi/php-snowflake) repository package.

Original Godruoyi License file included in LICENSES directory.

###  Health Score

46

—

FairBetter than 92% of packages

Maintenance80

Actively maintained with recent releases

Popularity17

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor1

Top contributor holds 86.4% 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 ~187 days

Total

5

Last Release

103d ago

PHP version history (2 changes)v3.1.1PHP ^8.2

v3.2.1PHP ^8.4

### Community

Maintainers

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

---

Top Contributors

[![secondmanveran](https://avatars.githubusercontent.com/u/97000801?v=4)](https://github.com/secondmanveran "secondmanveran (19 commits)")[![semantic-release-bot](https://avatars.githubusercontent.com/u/32174276?v=4)](https://github.com/semantic-release-bot "semantic-release-bot (3 commits)")

---

Tags

snowflake algorithmphp snowflakelaravel snowflake

###  Code Quality

TestsPest

### Embed Badge

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

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

###  Alternatives

[godruoyi/php-snowflake

An ID Generator for PHP based on Snowflake Algorithm (Twitter announced).

8662.7M74](/packages/godruoyi-php-snowflake)[fumeapp/modeltyper

Generate TypeScript interfaces from Laravel Models

199336.0k](/packages/fumeapp-modeltyper)[forjedio/inertia-table

Backend-driven dynamic tables for Laravel + Inertia.js

272.0k](/packages/forjedio-inertia-table)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

265.2k](/packages/aedart-athenaeum)

PHPackages © 2026

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