Giter Club home page Giter Club logo

php-uuid's Introduction

Build Status Coverage Status Scrutinizer Code Quality Latest Stable Version Total Downloads License SensioLabsInsight Donate

Uuid Generator

This class' intent is to encapsulate Uuid's latest and more secure versions removing the need to explicitly hard-code a Uuid version everywhere.

1. Installation

The recommended way to install the Uuid Generator is through Composer. Run the following command to install it:

php composer.phar require nilportugues/uuid

2. Usage

Usage is real simple, you can create your Uuid right away or under certain namespaces.

2.1. Without namespacing

This is the most common case. Usage is straight-forward:

<?php
use NilPortugues\Uuid\Uuid;

echo Uuid::create(); // "13dfa123-d7a6-4082-8b3f-513c28f5d691"

2.2. With namespacing

First of all, the following namespaces exists:

  • DNS Namespace
  • URL Namespace
  • OID (Object Id) Namespace
  • X500 Namespace

Code-wise it's use can be defined using a constant.

<?php
use NilPortugues\Uuid\Uuid;

echo Uuid::create(Uuid::NAMESPACE_DNS, 'nilportugues.com');

echo Uuid::create(Uuid::NAMESPACE_URL, 'http://nilportugues.com/robots.txt');

echo Uuid::create(Uuid::NAMESPACE_OID, 'Foo\Bar');

echo Uuid::create(Uuid::NAMESPACE_X500, '/c=us/o=Sun/ou=People/cn=Rosanna Lee');

More on its usage can be found here: http://tools.ietf.org/html/rfc4122#appendix-C

2.3. Uuid versions

Currently Uuid has 5 versions and while all of them are valid, usage of newest versions is always preferred. Lastest preferred versions are:

  • Uuid4 preferred over Uuid1.
  • Uuid5 preferred over Uuid3 and Uuid1

3. Quality

To run the PHPUnit tests at the command line, go to the tests directory and issue phpunit.

This library attempts to comply with PSR-1, PSR-2, and PSR-4. If you notice compliance oversights, please send a patch via pull request.

4. Author

Nil Portugués Calderó

5. License

The code base is licensed under the MIT license.

php-uuid's People

Contributors

nilportugues avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.