Tuesday, March 21, 2023
HomePHPRamsey UUID Provides Help for v8

Ramsey UUID Provides Help for v8


The favored PHP UUID library by Ben Ramsey launched a brand new model with assist for UUID v8, customized UUIDs:

The UUID package deal implements the UUID v8 draft spec, which outlines a couple of potentials causes one may think about using UUID v8:

  • An implementation want to embed additional data inside the UUID aside from what’s outlined on this doc.
  • An implementation has different software/language restrictions which inhibit the usage of one of many present UUIDs.

Here is an instance of producing a model 8 customized UUID:

1use RamseyUuidUuid;

2 

3/*

4The bytes ought to be a 16-byte octet string, an open blob of knowledge that you could be fill with 128 bits of knowledge. Nonetheless, bits 48 by 51 shall be changed with the UUID model area, and bits 64 and 65 shall be changed with the UUID variant. You have to not depend on these bits to your software wants.

5*/

6 

7$uuid = Uuid::uuid8("x00x11x22x33x44x55x66x77x88x99xaaxbbxccxddxeexff");

8 

9printf(

10 "UUID: %snModel: %dn",

11 $uuid->toString(),

12 $uuid->getFields()->getVersion()

13);

14 

15/*

16UUID: 00112233-4455-8677-8899-aabbccddeeff

17Model: 8

18*/

To be taught extra about utilizing model 8 UUIDs, learn Model 8: Customized within the ramsey/uuid Guide. You possibly can learn extra about UUID v8 draft spec if you would like extra technical particulars.

Observe: the Laravel framework v9 requires ramsey/uuid:^4.2.2 and you may replace dependencies to get the newest model of ramsey/uuid if you would like to experiment additional:

tinker example of uuidv8



RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments