josbeir/cakephp-uid
最新稳定版本:1.02
Composer 安装命令:
composer require josbeir/cakephp-uid
包简介
CakePHP plugin that provides various UID types for the ORM
README 文档
README
CakePHP UID Plugin
A CakePHP plugin providing a collection of UID field types for your applications.
You can follow ongoing discussion about native UID support on the official CakePHP issue tracker here. This plugin provides a solution until more convenient support is available in CakePHP core.
Features
- UUIDv4 field type
- UUIDv6 field type
- UUIDv7 field type
- ULID field type
Easily add modern, sortable unique identifiers to your CakePHP models.
Installation
Install via Composer:
composer require josbeir/cakephp-uid
Usage
Before using the UID field types in your schema, you need to map them using TypeFactory::map in your application bootstrap or plugin initialization:
If you want to use these types instead of CakePHP's native ones, you need to override the original types as shown below. CakePHP will handle the rest based on your database field settings.
- For UUID: use column type
UUID(when supported by your db) orBINARY(16)orCHAR(36): - FOR ULID: use column type
BINARY(16)orCHAR(26): - Remember that a UUID/BINARY is prefererd for performance reasons.
TypeFactory::map('binaryuuid', BinaryUuidV7Type::class); // Uses UUID V7 TypeFactory::map('binaryuuid', BinaryUlidType::class); // Uses ULID
Other possibilities:
TypeFactory::map('uuidv4', UuidV4Type::class); TypeFactory::map('uuidv6', UuidV6Type::class); TypeFactory::map('uuidv7', UuidV7Type::class); TypeFactory::map('ulid', UlidType::class); TypeFactory::map('binaryuuidv4', BinaryUuidV4Type::class); TypeFactory::map('binaryuuidv6', BinaryUuidV6Type::class); TypeFactory::map('binaryuuidv7', BinaryUuidV7Type::class); TypeFactory::map('binaryulid', BinaryUlidType::class);
Underlying Library
This plugin utilizes the Symfony UID component to generate, validate, and convert UIDs. Refer to the Symfony documentation for advanced usage and interoperability details.
License
Contributing
Pull requests are welcome. For major changes, please open an issue first.
统计信息
- 总下载量: 54
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-08-09