PHP Classes

PHP GUID Generator: Generate a globally unique identifier string

Recommend this page to a friend!
  Info   Documentation   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
StarStarStarStar 65%Total: 280 All time: 7,617 This week: 80Up
Version License PHP version Categories
guid-generator 1.0.0Freely Distributable5PHP 5, Data types, Windows
Description 

Author

This class can generate a globally unique identifier string.

The class can check if the MicroSoft Windows COM extension function com_create_guid exists and use it to generate a GUID string that represents an 128 bit number.

If the com_create_guid does not exist, the package can generate a GUID string using pure PHP functions available in all platforms.

Innovation Award
PHP Programming Innovation award nominee
June 2020
Number 5
Globally unique identifiers, also known as GUIDs, are useful to create strings that represent unique numbers

These unique numbers are used as identifiers for many types of application entities, like for instance, identifiers for licensed users of a system.

Microsoft Windows based systems provide a built-in means to generate GUIDs using a specific COM object.

This package can generate GUIDs using that COM object on Windows. It falls back to use a pure PHP based solution to generate GUIDs when the package is running on non-Windows systems.

Manuel Lemos
Picture of John Conde
  Performance   Level  
Name: John Conde <contact>
Classes: 6 packages by
Country: United States United States
Age: 51
All time rank: 2395327 in United States United States
Week rank: 195 Up20 in United States United States Up
Innovation award
Innovation award
Nominee: 1x

Recommendations

PHP API Key Generator
A random API key generator to server as access restriction to AP

Documentation

GUID (UUID) Generator

GUID (or UUID) is an acronym for "Globally Unique Identifier" (or "Universally Unique Identifier"). It is a 128-bit integer number used to identify resources. The term GUID is generally used by developers working with Microsoft technologies, while UUID is used everywhere else.

128-bits is big enough, and the generation algorithm is unique enough that if 1,000,000,000 GUIDs per second were generated for 1 year the probability of a duplicate would be only 50%. Or if every human on Earth generated 600,000,000 GUIDs there would only be a 50% probability of a duplicate. (1)

Format

In its canonical textual representation, the 16 octets of a UUID are represented as 32 hexadecimal (base-16) digits, displayed in five groups separated by hyphens, in the form 8-4-4-4-12 for a total of 36 characters (32 hexadecimal characters and 4 hyphens). For example: (2)

123e4567-e89b-12d3-a456-426614174000
xxxxxxxx-xxxx-Mxxx-Nxxx-xxxxxxxxxxxx

Usage

require('GuidGenerator.php');

echo GuidGenerator::create();

Special Thanks

Based on the code by Alex Axil as commented on at PHP.net (3)

Bibliography

  1. https://www.guidgenerator.com/
  2. https://en.wikipedia.org/wiki/Universally_unique_identifier
  3. https://www.php.net/manual/en/function.com-create-guid.php#99425

  Files folder image Files (2)  
File Role Description
Plain text file GuidGenerator.php Class GUID (UUID) Generator
Plain text file README.md Doc. README

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 0%
Total:280
This week:0
All time:7,617
This week:80Up
 User Ratings  
 
 All time
Utility:91%StarStarStarStarStar
Consistency:100%StarStarStarStarStarStar
Documentation:100%StarStarStarStarStarStar
Examples:-
Tests:-
Videos:-
Overall:65%StarStarStarStar
Rank:589