Working With UUIDs In PHP

It can be quite common to work with a Universally unique identifier (UUID) in software. They are all over the place. CMS's like Drupal can use them, databases like CouchDB use them, and in general they are all over the place. But, I did not find a good general purpose library in PHP for working with them. So, I wrote one.

The Gist

The package is called Lootils\UUID and it is a general purpose setup for dealing with v3, v4, and v5 UUIDs. Most of the time I've worked with v4 (random) UUIDs.

Random UUIDs is what the Drupal UUID module does and this is what I've found in most of the other implementations I've worked with. But, UUIDs can be namespaced and based on a value. Basically, they can be predictable. This has many nice advantages and is worth using in many situations.

Lootils\UUID does continuous integration via Travis CI and has unit tests for the different types of UUIDs.

Installation

The easiest way to install Lootils\UUID is via composer and it is listed on Packagist. In the require sections of your projects composer.json file add something like the following:

{
    "require": {
        lootils/uuid": "1.x"
    }
}

Alternately, you can download it and use it within a PSR-0 autoloader.

Feedback

I would appreciate any feedback on this. If there is a useful change please file an issue. If this is useful I would love to know. If there is a better alternative (so I don't have to maintain this) I would love to know about that as well.