Giter VIP home page Giter VIP logo

uuid's Introduction

A simple PHP class for working with Universally Unique Identifiers (UUIDs)

Generates, compresses, and expands Univerally Unique Identifers.

This class can generate UUIDs of versions 1 through 7.

It is also possible to create a new instance of this class from a UUID string of any version via the Uuid::createFromString() method.

This class implements the \Stringable interface, so getting the canonical string representation of a UUID is as simple as casting an instance of this class to string.

Because the canonical string representation of a UUID requires 36 characters, e.g. 4e917aef-2843-5b3c-8bf5-a858ee6f36bc, which can be quite cumbersome, this class can also compress and expand UUIDs to and from more compact representations for storage and other uses. In particular:

  • The Uuid::getBinary() method returns the 128-bit (16 byte) raw binary representation of a UUID. This form maintains the same sort order as the full form and is the most space-efficient form possible.

  • The Uuid::getShortForm() method returns a customized base 64 encoding of the binary form of the UUID. This form is 22 bytes long, maintains the same sort order as the full form, and is URL safe.

For convenience, two static methods, Uuid::compress() and Uuid::expand(), are available in order to simplify the process of converting an existing UUID string between the full, short, or binary forms.

For the purposes of software applications that use relational databases, the most useful UUID versions are v7 and v5:

  • UUIDv7 is ideal for generating permanently stored database keys, because these UUIDs naturally sort according to their chronological order of creation. This is the default version when generating a new UUID.

  • UUIDv5 is ideal for situations where UUIDs need to be generated on demand from pre-existing data, but will not be stored permanently. The generation algorithm for UUIDv5 always produces the same output given the same input, so these UUIDs can be regenerated any number of times without varying.

uuid's People

Contributors

sesquipedalian avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.