zauberfisch/silverstripe-uid-dataobject
Composer 安装命令:
composer require zauberfisch/silverstripe-uid-dataobject
包简介
SilverStripe module for adding an unique id (UUID) to a DataObject
README 文档
README
Utility/DataExtension for adding an unique ID (UUID or custom UID) to a DataObject.
Maintainer Contact
- Zauberfisch code@zauberfisch.at
Requirements
- php >=7.4
- silverstripe/framework >=4
- ramsey/uuid >=4
Installation
composer require "zauberfisch/silverstripe-uid-dataobject"- rebuild manifest (flush)
Documentation
Using UUID "Universally unique identifier" v4 (random)
This will generate unique IDs like 1ee9aa1b-6510-4105-92b9-7171bb2f3089.
<?php class MyDataObject extends \SilverStripe\ORM\DataObject { private static $extensions = [ \zauberfisch\UidDataObject\UuidDataObjectExtension::class, ]; private static $uuid_version = 4; // optional, default: 4 public function getCMSFields() { $fields = parent::getCMSFields(); $fields->removeByName('UUID'); $fields->addFieldsToTab( 'Root.Main', [ new \SilverStripe\Forms\ReadonlyField('UUID', "Universally unique identifier"), ]); return $fields; } }
Using UUID "Universally unique identifier" v1 (time & MAC based)
This will generate unique IDs like 123e4567-e89b-12d3-a456-426614174000.
NOTE that UUID v1 uses the current time, along with the MAC address (or node) for a network interface on the local machine. This means it is possible to uniquely identify the machine on which this
UUID was created. Keep that in mind when using v1 UUIDs in any user facing context.
<?php class MyDataObject extends \SilverStripe\ORM\DataObject { private static $extensions = [ \zauberfisch\UidDataObject\UuidDataObjectExtension::class, ]; private static $uuid_version = 1; public function getCMSFields() { $fields = parent::getCMSFields(); $fields->removeByName('UUID'); $fields->addFieldsToTab( 'Root.Main', [ new \SilverStripe\Forms\ReadonlyField('UUID', "Universally unique identifier"), ]); return $fields; } }
Using custom unique IDs
This will generate unique IDs like abc-1ee9aa1b.
This is useful if want shorter unique IDs or your own optional prefix/suffix. An example usecase is for use in URLSegments like /job-offers/abc-1ee9aa1b.
<?php class MyDataObject extends \SilverStripe\ORM\DataObject { private static $extensions = [ \zauberfisch\UidDataObject\CustomUidDataObjectExtension::class, ]; private static $custom_uid_prefix = 'abc-'; // optional: "" private static $custom_uid_suffix = ''; // optional, default: "" private static $custom_uid_length = 8; // optional, default: 8 public function getCMSFields() { $fields = parent::getCMSFields(); $fields->removeByName('UID'); $fields->addFieldsToTab( 'Root.Main', [ new \SilverStripe\Forms\ReadonlyField('UID', "My Unique ID"), ]); return $fields; } }
zauberfisch/silverstripe-uid-dataobject 适用场景与选型建议
zauberfisch/silverstripe-uid-dataobject 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 452 次下载、GitHub Stars 达 1, 最近一次更新时间为 2022 年 01 月 16 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「id」 「uuid」 「guid」 「silverstripe」 「UID」 「unique」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 zauberfisch/silverstripe-uid-dataobject 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 zauberfisch/silverstripe-uid-dataobject 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 zauberfisch/silverstripe-uid-dataobject 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Paramconverter, Normalizer and Form Type for Ramsey Uuid
A PHP library for generating and working with identifiers, including UUIDs, ULIDs, and Snowflakes
DrUUID RFC 4122 library for PHP
Trait to generate uuid when creating models
Analytics chooser extensions for site settings.
统计信息
- 总下载量: 452
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 11
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: BSD-3-Clause
- 更新时间: 2022-01-16