• Stars
    star
    18
  • Rank 1,208,065 (Top 24 %)
  • Language
    PHP
  • License
    MIT License
  • Created about 4 years ago
  • Updated 7 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

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

UUID

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)

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!