PHPackages                             dekuan/dedid - 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. dekuan/dedid

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

dekuan/dedid
============

An unique id generator for distributed database by DeKuan, Inc.

1.0.7(8y ago)221.4k8[1 issues](https://github.com/dekuan/dedid/issues)4proprietaryPHPPHP &gt;=7.0.0

Since Aug 3Pushed 8y ago3 watchersCompare

[ Source](https://github.com/dekuan/dedid)[ Packagist](https://packagist.org/packages/dekuan/dedid)[ RSS](/packages/dekuan-dedid/feed)WikiDiscussions master Synced 4w ago

READMEChangelog (8)Dependencies (1)Versions (10)Used By (4)

dekuan/dedid
============

[](#dekuandedid)

An unique id generator for primary key of distributed database. This implementation of the algorithm was referenced by Twitter Snowflake, but in the last 12 bits you can not only use the random numbers, but also get a hash value by your specified string.

- [简体中文版文档](README.chs.md)

ALGORITHM
=========

[](#algorithm)

### Bit structure

[](#bit-structure)

It's a 64 bits bigint.

```
0 xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx x xxxxx xxxxx xxxx xxxxxxxx

```

### Details

[](#details)

PositionLengthUsageRemark01ReservedAlways be 01~4141Escaped Time (in millisecond)0~69 years42~465Number of data center0~3147~515Number of data node in the data center0~3152~6312Random / Hash0~4095Bit marks
=========

[](#bit-marks)

### Center

[](#center)

```
0 00000000 00000000 00000000 00000000 00000000 0 11111 00000 0000 00000000

00000000 00000000 00000000 00000000 00000000 00111110 00000000 00000000

00       00       00       00       00       3E       00       00

```

### Node

[](#node)

```
0 00000000 00000000 00000000 00000000 00000000 0 00000 11111 0000 00000000

00000000 00000000 00000000 00000000 00000000 00000001 11110000 00000000

00       00       00       00       00       01       F0       00

```

### Escaped Time

[](#escaped-time)

```
0 11111111 11111111 11111111 11111111 11111111 1 00000 00000 0000 00000000

01111111 11111111 11111111 11111111 11111111 11000000 00000000 00000000

7F       FF       FF       FF       FF       C0       00       00

```

### Random or Hash value

[](#random-or-hash-value)

```
0 00000000 00000000 00000000 00000000 00000000 0 00000 00000 1111 11111111

00000000 00000000 00000000 00000000 00000000 00000000 00001111 11111111

00       00       00       00       00       00       0F       FF

```

HOW TO USE
==========

[](#how-to-use)

### Create an new id normally

[](#create-an-new-id-normally)

```
$cDId		= CDId::getInstance();
$nCenter	= 0;
$nNode		= 1;

$arrD		= [];
$nNewId	= $cDId->createId( $nCenter, $nNode, null, $arrD );

echo "new id = " . $nNewId . "\r\n";
print_r( $arrD );

```

##### output

[](#output)

```
new id = 114654484990270790
Array
(
    [center] => 0
    [node] => 1
    [time] => 27335759399
    [rand] => 3398
)

```

### Create an new id with crc32 hash value by a specified string

[](#create-an-new-id-with-crc32-hash-value-by-a-specified-string)

```
$cDId		= CDId::getInstance();
$nCenter	= 0;
$nNode		= 15;

$sSrc		= "dekuan";
$arrD		= [];
$nNewId	= $cDId->createId( $nCenter, $nNode, $sSrc, $arrD );

echo "new id = " . $nNewId . "\r\n";
print_r( $arrD );

```

##### output

[](#output-1)

```
new id = 114654631304370386
Array
(
    [center] => 0
    [node] => 1
    [time] => 27335794283
    [rand] => 2258
)

```

### Parse an id for getting the details

[](#parse-an-id-for-getting-the-details)

```
$cDId		= CDId::getInstance();
$arrId		= $cDId->parseId( 114654631304370386 );
print_r( $arrId );

```

##### output

[](#output-2)

```
Array
(
    [center] => 0
    [node] => 1
    [time] => 27335794283
    [rand] => 2258
)

```

INSTALL
=======

[](#install)

```
# composer require dekuan/dedid

```

For more information, please visit

###  Health Score

35

—

LowBetter than 77% of packages

Maintenance19

Infrequent updates — may be unmaintained

Popularity26

Limited adoption so far

Community19

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor1

Top contributor holds 60% 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 ~20 days

Recently: every ~35 days

Total

8

Last Release

3110d ago

PHP version history (2 changes)1.0.0PHP &gt;=5.3.0

1.0.6PHP &gt;=7.0.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/e724f9d4634032d0421f34b90aec73df3883dc01dc188ac8a71874ee70a34b88?d=identicon)[dekuan](/maintainers/dekuan)

---

Top Contributors

[![xingworld](https://avatars.githubusercontent.com/u/5023258?v=4)](https://github.com/xingworld "xingworld (15 commits)")[![dekuan](https://avatars.githubusercontent.com/u/18378704?v=4)](https://github.com/dekuan "dekuan (10 commits)")

---

Tags

composerdistributed-databaselaravelphpunique-id-generator

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/dekuan-dedid/health.svg)

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

###  Alternatives

[aerni/livewire-forms

A Statamic forms framework powered by Laravel Livewire

2914.3k](/packages/aerni-livewire-forms)[jimbojsb/emogrify

CSS inliner for HTML Emails. Great with Swiftmailer and Zend Mail

1627.8k1](/packages/jimbojsb-emogrify)

PHPackages © 2026

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