ndtan/id-generator
最新稳定版本:v0.3.0
Composer 安装命令:
composer require ndtan/id-generator
包简介
NDT ID Generator — pluggable PHP ID generation library (UUID v4/v6/v7/v8, ULID, Snowflake, NanoID, KSUID, Mongo ObjectId, ShortUUID) with per-driver configuration and integrations for Laravel & Doctrine.
关键字:
README 文档
README
Pluggable PHP ID generation library — UUID v4/v6/v7/v8, ULID, Snowflake, NanoID, KSUID, Mongo ObjectId, ShortUUID — with per-driver options and integrations for Laravel & Doctrine.
Namespace: ndtan · PHP 8.1+
Features
- ✅ Multiple strategies: UUID v4/v6/v7/v8, ULID (monotonic option), Snowflake, NanoID, KSUID, Mongo ObjectId, ShortUUID(Base58)
- ✅ Pluggable drivers via
IdGeneratorInterface+Manager - ✅ Per-driver configuration (epoch/worker/datacenter/alphabet/size/monotonic…)
- ✅ Framework integrations: Laravel ServiceProvider, Doctrine DBAL types
- ✅ Tests + GitHub Actions CI, MIT License
Installation
composer require ndtan/id-generator
Quick Start
use ndtan\Manager; use ndtan\Uuid\UuidV7Generator; use ndtan\Ulid\UlidGenerator; use ndtan\Snowflake\SnowflakeGenerator; $mgr = new Manager([ 'default' => 'uuid7', 'drivers' => [ 'uuid7' => [ 'class' => UuidV7Generator::class ], 'ulid' => [ 'class' => UlidGenerator::class, 'monotonic' => true ], 'snowflake' => [ 'class' => SnowflakeGenerator::class, 'epoch' => '2020-01-01T00:00:00Z' ], ] ]); echo $mgr->generate(); // UUIDv7 echo $mgr->driver('ulid')->generate(); // ULID
Documentation
- Getting started: docs/GETTING_STARTED.md
- Driver reference (all options): docs/DRIVERS.md
- Laravel & Doctrine integration: docs/INTEGRATIONS.md
Roadmap
- Benchmarks workflow, PHPStan/Psalm
- Additional encoders (Base32/Base64 for binaries)
- More framework snippets (Symfony bundle, Laminas)
License
MIT © Tony Nguyen
统计信息
- 总下载量: 2
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-09-21