abmmhasan / uuid
UUID (v1, v3-v5) Generator (RFC4122)
Installs: 2 255
Dependents: 1
Suggesters: 0
Security: 0
Stars: 18
Watchers: 5
Forks: 1
Open Issues: 0
Requires
- php: >=7.1
Suggests
- inforcyph/uid: If your library uses PHP version 8 or higher, it is recommended to use [infocyph/UID](https://github.com/infocyph/UID) instead.
README
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!