PHPackages                             myphps/my-id - 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. myphps/my-id

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

myphps/my-id
============

基于workerman|swoole的ID生成服务(单进程、主从服务模式)

2.1.1(1y ago)011MITPHPPHP &gt;=7.1

Since Jul 2Pushed 1y ago1 watchersCompare

[ Source](https://github.com/ncwsky/my-id)[ Packagist](https://packagist.org/packages/myphps/my-id)[ Docs](https://github.com/ncwsky/my-id)[ RSS](/packages/myphps-my-id/feed)WikiDiscussions main Synced yesterday

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

基于workerman|swoole的ID生成服务(单进程、主从服务模式)

> 全局唯一数字id 最大到9223372036854775807
> id自增 重启可能存在id浪费
> 支持批量获取id
> 支持生成奇偶的id
> 支持http+tcp接入 两种id数据存储方式json文件或mysql
> 使用主(单进程)从(多进程)服务模式时id不保持连续性

\##安装运行
mkdir myid cd myid

```
composer require myphps/my-id

cp vendor/myphps/my-id/run.example.php run.php
cp vendor/myphps/my-id/conf.example.php conf.php
chmod +x run.php

修改 run.php conf.php配置
运行 ./run.php

./run.php -h 帮助
./run.php -t master 主服务
./run.php -t worker 从服务(需要配置主服务连接信息) id从这里获取

```

\##使用

> delta int DEFAULT 1 每次增量值 范围（1-999）
> step int DEFAULT 100000 步长,最小1000
> init\_id int DEFAULT 0 id初始值

> http模式

```
获取id /id?name=xxx[&size=x]&key=认证key
初始id /init?name=xxx[&&delta=1&step=1000&init_id=0]

```

> tcp模式

```
获取id 发送 name=xx[&size=x]+"\r\n"
初始id 发送 a=init&name=xxx[&delta=1&step=1000&init_id=0]+"\r\n"

```

\##TODO
数据意外被删除服务未停止的情况自动重新生成数据
管理面板
出错通知
监控数据

\##备注
initId 初始id
nextId 获取id
updateId 更新id

单进程服务能保持id连续性
主从服务模式id不是连续性的
主从服务模式 在从服务的多进程里记录大量id缓存并自动预载最新id，主服务挂掉的时有足够时间来重启服务（这个过程有大量id被浪费掉）

###  Health Score

21

—

LowBetter than 18% of packages

Maintenance31

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity37

Early-stage or recently created project

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

Total

2

Last Release

711d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/9b74c5891fa18ea096b482ac20434e2847f4ed94292615ac6c5703251b7bd4c1?d=identicon)[ep1086](/maintainers/ep1086)

---

Tags

id

### Embed Badge

![Health badge](/badges/myphps-my-id/health.svg)

```
[![Health](https://phpackages.com/badges/myphps-my-id/health.svg)](https://phpackages.com/packages/myphps-my-id)
```

###  Alternatives

[cybercog/laravel-optimus

An Optimus bridge for Laravel. Id obfuscation based on Knuth's multiplicative hashing method.

195578.5k](/packages/cybercog-laravel-optimus)[pugx/shortid-php

An implementation of shortid in PHP

52617.0k3](/packages/pugx-shortid-php)[alicfeng/identity-card

IdentityCard Library

1238.7k](/packages/alicfeng-identity-card)[identifier/identifier

Common Interfaces and Factories for Identifiers

3233.4k1](/packages/identifier-identifier)[ada-u/chocoflake

64bit time based id generator

14118.2k](/packages/ada-u-chocoflake)[byrokrat/id

Data types for swedish personal identity and corporation id numbers

15101.9k5](/packages/byrokrat-id)

PHPackages © 2026

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