2017 © Pedro Peláez
 

library uuid

image

jp3cki/uuid

  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 4 % Grown

The README.md

jp3cki/uuid

Latest Stable Version License, (*1)

The simple UUID implementation., (*2)

Requirements

  • PHP ≥ 7.0 (64 bit)
  • Basic extensions
    • PCRE (preg)
    • Hash

Install

$ composer.phar require jp3cki/uuid

Usage

Timestamp-based UUID (version 1)

<?php

declare(strict_types=1);

require_once(__DIR__ . '/vendor/autoload.php'); // composer autoloader

use jp3cki\uuid\Uuid;

echo Uuid::v1() . "\n";                    // outputs: b45d8864-9db7-11eb-9ef1-4e3ad45d3da7
echo Uuid::v1('08:00:2b:01:02:03') . "\n"; // outputs: b45d9c96-9db7-11eb-8ec4-08002b010203

Random-based UUID (version 4, aka GUID)

<?php

declare(strict_types=1);

require_once(__DIR__ . '/vendor/autoload.php'); // composer autoloader

use jp3cki\uuid\Uuid;

echo Uuid::v4() . "\n"; // outputs: 4c9d5550-f58e-4259-ba00-5e59b15895a0

Hash-based UUID (version 3 or 5)

<?php

declare(strict_types=1);

require_once(__DIR__ . '/vendor/autoload.php');

use jp3cki\uuid\Uuid;
use jp3cki\uuid\NS as UuidNS;

// version 3, MD5
echo Uuid::v3(UuidNS::dns(), 'www.example.com') . "\n"; // output: 5df41881-3aed-3515-88a7-2f4a814cf09e

// version 5, SHA-1
echo Uuid::v5(UuidNS::dns(), 'www.example.com') . "\n"; // output: 2ed6657d-e927-568b-95e1-2665a8aea6a2

Predefined UUIDs (for "namespace"):, (*3)

  • jp3cki\uuid\NS::nil() : 00000000-0000-0000-0000-000000000000
  • jp3cki\uuid\NS::dns() : 6ba7b810-9dad-11d1-80b4-00c04fd430c8
  • jp3cki\uuid\NS::url() : 6ba7b811-9dad-11d1-80b4-00c04fd430c8
  • jp3cki\uuid\NS::oid() : 6ba7b812-9dad-11d1-80b4-00c04fd430c8
  • jp3cki\uuid\NS::x500() : 6ba7b814-9dad-11d1-80b4-00c04fd430c8

License

Under the MIT License., (*4)

Please refer the LICENSE file., (*5)

Breaking Changes

  • v2.0.0, (*6)

    • This library no longer works with the 32-bit version of PHP., (*7)

    • All public classes are marked as final. You are not permitted to inherit classes from this library., (*8)

    • The parameter type is now explicitly specified. I believe most users will not be affected by this, but you may get unexpected results if you call it using a variable of the wrong type., (*9)

  • v1.0.0, (*10)

    • Changed minimum requirement to PHP 7.0

The Versions

30/08 2016

dev-master

9999999-dev

  Sources   Download

MIT

The Requires

  • php >= 5.4
  • ext-pcre *
  • ext-hash *

 

The Development Requires

30/08 2016

v0.1.1

0.1.1.0

  Sources   Download

MIT

The Requires

  • php >= 5.4
  • ext-pcre *
  • ext-hash *

 

The Development Requires

27/03 2016

v0.1.0

0.1.0.0

  Sources   Download

MIT

The Requires

  • php >= 5.4
  • ext-pcre *
  • ext-hash *

 

The Development Requires