UUID (v1, v3-v5) Generator (RFC4122)

2.01 2024-04-26 05:58 UTC

This package is auto-updated.

Last update: 2024-10-26 06:56:54 UTC


README

GitHub Workflow Status Codacy Badge Libraries.io dependency status for GitHub repo Packagist Downloads License: MIT Packagist Version Packagist PHP Version Support GitHub code size in bytes

UUID (v1, v3-v5) Generator (RFC4122)

Note: If your library uses PHP version 8 or higher it is recommended to use infocyph/UID instead.

Prerequisites

Language: PHP 7.1/+

Installation

composer require abmmhasan/uuid

Usage

v1

// Get v1 UUID (Time based)
\AbmmHasan\UUID\GenerateUuid::v1();

// Get generated node, for further use
$node = \AbmmHasan\UUID\GenerateUuid::getNode();

// Pass your pre-generated node (for node specific UUID)
\AbmmHasan\UUID\GenerateUuid::v1($node);

// alternatively can also use
\AbmmHasan\UUID\uuid1();

v3

// Get v3 UUID for 'TestString' (default X500 namespace)
\AbmmHasan\UUID\GenerateUuid::v3('TestString');

/**
* Get v3 UUID for an URL & pre-defined namespace
* You can pass X500, URL, OID, DNS (check RFC4122 #Appendix C)
*/
\AbmmHasan\UUID\GenerateUuid::v3('abmmhasan.github.io','url');

// You can generate a random UUID & use as namespace as well
\AbmmHasan\UUID\GenerateUuid::v3('abmmhasan.github.io','fa1700dd-828c-4d1b-8e6d-a6104807da90');

// alternatively can also use
\AbmmHasan\UUID\uuid3();

v4

// Get v4 UUID (completely random)
\AbmmHasan\UUID\GenerateUuid::v4();

// alternatively can also use
\AbmmHasan\UUID\uuid4();

v5

// Get v5 UUID for 'TestString' (default X500 namespace)
\AbmmHasan\UUID\GenerateUuid::v5('TestString');

/**
* Get v5 UUID for an URL & pre-defined namespace
* You can pass X500, URL, OID, DNS (check RFC4122 #Appendix C)
*/
\AbmmHasan\UUID\GenerateUuid::v5('abmmhasan.github.io','url');

// You can generate a random UUID & use as namespace as well
\AbmmHasan\UUID\GenerateUuid::v5('abmmhasan.github.io','fa1700dd-828c-4d1b-8e6d-a6104807da90');

// alternatively can also use
\AbmmHasan\UUID\uuid5();

v2

/** 
* Not supported! 
*/

Support

Having trouble? Create an issue!