PHPackages                             gendoria/cruftflake - 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. gendoria/cruftflake

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

gendoria/cruftflake
===================

Unique ID generator based on Twitter Snowflake, but in PHP with a simple ZeroMQ interface.

2.2.2(9y ago)032MITPHPPHP &gt;=5.3.9

Since Mar 20Pushed 4y ago2 watchersCompare

[ Source](https://github.com/Gendoria/cruftflake)[ Packagist](https://packagist.org/packages/gendoria/cruftflake)[ Docs](https://github.com/gendoria/cruftflake)[ RSS](/packages/gendoria-cruftflake/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (5)Versions (9)Used By (0)

CruftFlake
==========

[](#cruftflake)

[![Build Status](https://camo.githubusercontent.com/f5273873da886ce05e84008885263ffc72f0e6b58cbc537037874d7e7f1c160c/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f47656e646f7269612f6372756674666c616b652f6d61737465722e737667)](https://travis-ci.org/Gendoria/cruftflake)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/0ff48c39e06cae1427924465c38150792210e38a502607f0df61cc20de9963eb/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f47656e646f7269612f6372756674666c616b652e737667)](https://scrutinizer-ci.com/g/Gendoria/cruftflake/?branch=master)[![Code Coverage](https://camo.githubusercontent.com/a02859953f5d20fc0c254a2780e3ae1c670941148c9e46c24c58edd6ca9b738d/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f47656e646f7269612f6372756674666c616b652e737667)](https://scrutinizer-ci.com/g/Gendoria/cruftflake/?branch=master)[![Downloads](https://camo.githubusercontent.com/f0b993e12a512fde9fa4a7a158f037740a66c0ff59214631203052529b2f199c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f67656e646f7269612f6372756674666c616b652e737667)](https://packagist.org/packages/gendoria/cruftflake)[![Latest Stable Version](https://camo.githubusercontent.com/57481e5454efeaae617f1650d61efe8504870e2635107dcff90d40df1aff0761/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f67656e646f7269612f6372756674666c616b652e737667)](https://packagist.org/packages/gendoria/cruftflake)

Unique ID generator based on [Twitter Snowflake](https://github.com/twitter/snowflake), but in PHP with a simple ZeroMQ interface (rather than Thrift).

This is a rewrite of [dvomedia/cruftflake](https://github.com/dvomedia/cruftflake). It organizes the code in modules and adds several interfaces, allowing easier extension of other server and configuration mechanisms.

Implementation
--------------

[](#implementation)

The implementation copies Twitter - generating 64 bit IDs.

- time - 41 bits
- configured machine ID - 10 bits
- sequence number - 12 bits

Has a custom epoch that means it can generate IDs until 2081-09-06 (not the same epoch as Snowflake).

### ZooKeeper for config coordination

[](#zookeeper-for-config-coordination)

We use ZooKeeper to store which machine IDs are in use. When a new node starts up for the first time it **must** be able to contact the ZooKeeper cluster and create a new node. It will look at all the existing nodes and then (if it can't find its own Mac Address) attempt to claim a free one.

I was using Ephemeral nodes for this - similar(ish) to a lock pattern but this had the issue that the node needed to remain connected to ZK throughout its lifetime -- this way it doesn't.

The downside is that potentially the 1024 possible machine IDs will "fill up" and need to be manually pruned.

Running
-------

[](#running)

Installation via composer:

```
	{
    	"require": {
	        "gendoria/cruftflake": "*"
		}
	}
```

There are several example scripts provided for playing about with. Both require previous composer update.

1. The generator (the server)

    ```
        ./examples/server.php
    ```
2. A client, that will generate N IDs and dump to STDOUT

    ```
    ./examples/client.php -n 100
    ```
3. A client, that will ask server for generator status

    ```
    ./examples/status.php
    ```

For client examples to work, server example has to be be running.

Dependencies
------------

[](#dependencies)

- ZeroMQ
- ZooKeeper (if you want to use ZooKeeper centralized configuration)
- Doctrine DBAL &gt;= 2.3.0 (if you want Doctrine DBAL centralized configuration)

Composer requires php-zmq module installed.

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor1

Top contributor holds 78.6% 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 ~166 days

Recently: every ~29 days

Total

8

Last Release

3630d ago

Major Versions

1.0.0 → 2.0.02016-02-04

PHP version history (3 changes)2.0.0PHP &gt;=5.3.0

2.2.0PHP &gt;=5.3.2

2.2.2PHP &gt;=5.3.9

### Community

Maintainers

![](https://www.gravatar.com/avatar/0295f054c19f793a2107980d5dffc75dda33e308f5c54b6d58d83de0b5ca1792?d=identicon)[TiS](/maintainers/TiS)

---

Top Contributors

[![bobbydeveaux](https://avatars.githubusercontent.com/u/5550105?v=4)](https://github.com/bobbydeveaux "bobbydeveaux (11 commits)")[![TiS](https://avatars.githubusercontent.com/u/233690?v=4)](https://github.com/TiS "TiS (2 commits)")[![scrutinizer-auto-fixer](https://avatars.githubusercontent.com/u/6253494?v=4)](https://github.com/scrutinizer-auto-fixer "scrutinizer-auto-fixer (1 commits)")

---

Tags

cruftflake

### Embed Badge

![Health badge](/badges/gendoria-cruftflake/health.svg)

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

###  Alternatives

[phpro/soap-client

A general purpose SoapClient library

8885.6M46](/packages/phpro-soap-client)[cognesy/instructor-php

The complete AI toolkit for PHP: unified LLM API, structured outputs, agents, and coding agent control

310107.9k1](/packages/cognesy-instructor-php)[php-soap/wsdl

Deals with WSDLs

173.5M12](/packages/php-soap-wsdl)[aedart/athenaeum

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

255.2k](/packages/aedart-athenaeum)

PHPackages © 2026

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