alexhalchenko/uuid
Composer 安装命令:
composer require alexhalchenko/uuid
包简介
A UUID fieldtype for Statamic that auto-generates a stable, write-once unique ID for entries.
README 文档
README
# Statamic UUIDA UUID fieldtype for Statamic that automatically generates a stable, unique identifier for an entry — and then leaves it alone. Set it once, reference it forever: ideal for public-facing IDs, external-system keys, idempotency keys, or anywhere you need an immutable handle that isn't the slug.
Features
- Automatic — generates an ID the moment an entry is saved; no manual input.
- Write-once and stable — once a value exists it's never regenerated, so it's safe to reference from other systems.
- Two formats — a full UUID (
9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d) or a compact short ID (8 characters, e.g.a1b2c3d4). - Optional prefix — e.g.
POST-,USER-. - Defaults and overrides — set defaults addon-wide and override them per field in any blueprint.
- No custom JS — reuses Statamic's native text field component in the CP.
Requirements
| PHP | ^8.3 |
| Statamic | ^6.0 |
| Laravel | ^13.0 |
Installation
composer require alexhalchenko/uuid
The fieldtype auto-registers via Laravel package discovery.
Usage
Add a UUID field to any blueprint. On the next save the field populates automatically and then stays fixed for the life of the entry.
Per-field options
| Option | Description |
|---|---|
| Prefix | Text prepended to the generated ID (overrides the addon default). |
| Format | UUID (full) or Short ID (8 chars) — overrides the addon default. |
Addon-wide defaults
Set defaults once under CP → Addons → UUID → Settings:
- Default prefix — optional text prepended to every generated ID.
- Default format —
UUIDorShort ID(defaults toUUID).
Individual fields override these whenever they specify their own prefix or format.
How it works
The fieldtype only generates a value when the field is empty, which is what makes the ID write-once and stable across edits:
$id = $format === 'short'
? Str::lower(Str::random(8)) // a1b2c3d4
: (string) Str::uuid(); // 9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d
return $prefix . $id;
License
**[dnsk.work](https://dnsk.work)** — a UI/UX design agency without the agency part.Senior-led, embedded, no six-week process.
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-06-22