lekoala/silverstripe-uuid

Uuid data extension for SilverStripe

Fund package maintenance!
lekoala

Installs: 1 604

Dependents: 1

Suggesters: 0

Security: 0

Stars: 2

Watchers: 4

Forks: 1

Open Issues: 1

Type:silverstripe-vendormodule

1.1.2 2023-10-24 16:07 UTC

This package is auto-updated.

Last update: 2024-04-05 10:34:48 UTC


README

Build Status Build Status Scrutinizer Code Quality Code Coverage Build Status codecov.io

Latest Stable Version Latest Unstable Version Total Downloads License Monthly Downloads Daily Downloads

Easily add uuid to your DataObjects

Getting started

Simply add the extension to your DataObject

MyDataObject:
  extensions:
    - LeKoala\Uuid\UuidExtension

Call UuidExtension::getByUuid(MyDataObject::class, $uuid) to retrieve the record by Uuid. Since that's really ugly, you can also use the HasUuid trait on your classes to return a properly type hinted class.

Usage in templates

In your templates, use UuidSegment to ensure Uuid value is generated on the record. UuidSegment are base62 encoded in order to be shorter and more readable.

Getting readable values

Since Uuid's are stored in binary format for performance reason, you need to call $myObject->dbObject('Uuid')->Nice() to get a readable value.

Upgrade to Ramsey v4

If you happen to upgrade from previous versions you might want to check this guide

TODO

  • Postgres compat

Worth reading

Storing UUID Values in MySQL GUID/UUID Performance Laravel: The mysterious “Ordered UUID”: offer a good overview of the situation although it's a bit laravel specific

Compatibility

Tested with 4.4 and up

Maintainer

LeKoala - thomas@lekoala.be