定制 pixielity/laravel-uuid 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

pixielity/laravel-uuid

Composer 安装命令:

composer require pixielity/laravel-uuid

包简介

UUID generation and management utilities

README 文档

README

Uuid

The UUID Module provides a robust and flexible API for generating and managing Universally Unique Identifiers (UUIDs). It supports various UUID versions (1, 3, 4, and 5) and includes utilities for validation, namespace-based generation, and lexicographically sortable UUIDs.

Features • Generate UUIDs for versions 1, 3, 4, and 5. • Supports namespace-based UUID generation. • Generate lexicographically sortable UUIDs. • Validate UUID strings for correctness. • Custom exceptions for error handling.

Installation

To use the UUID Module, follow these steps:

  1. Install the package (if applicable):

composer require pixielity/laravel-framework-uuid

  1. Configure it in your application or register the service provider (if required).

Usage

Importing the Facade

The Uuid facade offers a convenient way to interact with the UUID Manager:

use Pixielity\Uuid\Facades\Uuid;

Available Methods

  1. generate(int $version, ?string $namespace = null, ?string $name = null)

Generates a UUID for the specified version. Supports versions 1, 3, 4, and 5.

// Generate a version 4 UUID $uuidV4 = Uuid::generate(4);

// Generate a version 5 UUID using a namespace and name $uuidV5 = Uuid::generate(5, 'namespace-uuid', 'resource-name');

  1. orderedUuid()

Generates a lexicographically sortable UUID, ideal for database indexing.

$orderedUuid = Uuid::orderedUuid();

  1. uuid1()

Generates a version 1 UUID based on timestamp and node.

$uuidV1 = Uuid::uuid1();

  1. uuid3(string $namespace, string $name)

Generates a version 3 UUID using a namespace and name (MD5 hashing).

$uuidV3 = Uuid::uuid3('namespace-uuid', 'resource-name');

  1. uuid4()

Generates a random version 4 UUID.

$uuidV4 = Uuid::uuid4();

  1. uuid5(string $namespace, string $name)

Generates a version 5 UUID using a namespace and name (SHA-1 hashing).

$uuidV5 = Uuid::uuid5('namespace-uuid', 'resource-name');

  1. namespaceUuid(string $namespace, string $name)

Generates a namespace-based UUID, equivalent to uuid5.

$namespaceUuid = Uuid::namespaceUuid('namespace-uuid', 'resource-name');

  1. isValid(string $uuid)

Validates whether a given string is a valid UUID.

$isValid = Uuid::isValid('550e8400-e29b-41d4-a716-446655440000');

Examples

Generating and Validating a UUID

use Pixielity\Uuid\Facades\Uuid;

// Generate a UUID version 4 $uuid = Uuid::uuid4(); echo "Generated UUID: $uuid";

// Validate the UUID if (Uuid::isValid($uuid)) { echo "The UUID is valid."; } else { echo "The UUID is invalid."; }

Generating a Namespace-Based UUID

$namespaceUuid = Uuid::namespaceUuid('my-namespace-uuid', 'my-resource-name'); echo "Namespace-based UUID: $namespaceUuid";

Constants

The module defines constants for common use cases: • UUID Field Name:

const UUID = 'uuid';

You can reference this constant for database schema fields or application logic.

Exceptions

All methods throw the Pixielity\Foundation\Exceptions\Exception in cases where UUID generation or validation fails. Ensure you wrap calls in try-catch blocks for error handling.

try { $uuid = Uuid::generate(6); // Invalid version } catch (Exception $e) { echo "Error: " . $e->getMessage(); }

Contributing

  1. Fork the repository.
  2. Create a feature branch: git checkout -b feature-name.
  3. Commit your changes: git commit -m "Add feature description".
  4. Push to the branch: git push origin feature-name.
  5. Open a pull request for review.

License

This module is open-source software licensed under the MIT license.

Support

If you encounter any issues or have questions, feel free to open an issue in the repository or contact the support team.

pixielity/laravel-uuid 适用场景与选型建议

pixielity/laravel-uuid 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 0 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 02 月 08 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「uuid」 「laravel」 「identifier」 「pixielity」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 pixielity/laravel-uuid 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 pixielity/laravel-uuid 我们能提供哪些服务?
定制开发 / 二次开发

基于 pixielity/laravel-uuid 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 0
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 31
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-02-08