Download the PHP package charm/uuid without Composer

On this page you can find all versions of the php package charm/uuid. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package uuid

A very fast UUID and snowflake generator

After looking at other libraries, they seem very complex for the most common use case: generating UUIDs. Now, UUIDs are quite complex in themselves, and it is easy to make mistakes so that the UUID is not truly unique. That's why I feel the library should be as simple as possible, so that it is easy to review.

Features:

This library provides two classes and has no dependencies and performs very well. The UUID v4 is cryptographic random (via random_bytes()), while UUID v1 tries to find the MAC address or another unique machine ID. To reduce the risk of collisions, the process id is used to to reduce the chance of a single machine generating two identical IDs.

Benchmarks

First UUID is generated almost as quickly as the native PECL extension

Edit

Faster then the native PECL extension for many UUIDs.

Edit

Summary

See the BENCHMARKS.md file for full details. The noteworthy details are:

  1. Less then 1 ms to generate the first UUID, 10.5 milliseconds faster than ramsey/uuid for UUID v1 and 3.9 ms faster for UUID v4.
  2. Overhead is related to loading of the source files.
Library Avg time first UUID 1 Avg. time first UUID 4 100 000 UUID 1 100 000 UUID 4
charm/uuid 0.75 ms 0.50 ms 479.41 ms 495.17 ms
ramsey/uuid 10.05 ms 4.34 ms 1,944.46 ms 779.63 ms
NATIVE pecl:uuid extension 0.51 ms 0.16 ms 528.75 ms 1,091.64 ms

Are these UUIDs truly unique?

UUID(4)

The random UUID(4) generated by this library are industrial strength, directly using the entropy from the operating system via the random_bytes() function.

UUID(1)

The time and place based UUID(1) algorithm was implemented while taking into account bug reports and experiences made in other libraries. Subtle issues that can arise is related to forking of the process and The algorithm for building the bytes is an exact port of the C code provided in appendix A of the RFC 4122.

However, the microtime(true) function in PHP does not provide an accurate enough time resolution,

A lot of effort was put into defining the UUID standard, and a they are considered to be unique for all practical purposes.

UUID v4 is the simplest to use, but they require 16 bytes of storage each. They need no configuration, and they can be generated very quickly. If all companies in the world generate a total of 1 billion UIDs every second, the first collision is expected to happen after about 85 years. After those 85 years, most of these UUIDs will have vanished anyway.

Snowflake ID are only 8 bytes (64 bits) and can safely be be used inside your own databases. They were invented by Twitter and is used to generate unique IDs for tweets, users, things, images and so on. To ensure uniqueness, you may configure a unique machineId, but the library will automatically pick an available machine id from the operating system if you don't.

UUID v1 is a "coordinate" using the clock and a unique machine id derived from the mac address or another unique 48 bit machine identifier. They are also automatically configured in this library.

Warning

Please run some tests in your environment before using this library. Particularly, ensure that the server has enough entropy available if you're using UUID version 4. Entropy is random numbers generated from network noise and other sources.

UUIDs version 4 are considered production ready, but the other IDs need some more scrutiny before we can declare them production ready. Please let me know if you spot any problems.

Quick Start

If you're not using a service container, the quickest way to begin is by using the function Charm\Id::make(). The returned value will be a cryptographically random 128 bit value in UUID v4 form (XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX).

Installation

As with most PHP packages, install composer and run

Alternatively you can of course clone the repository from https://github.com/charm-php/uuid and include the ./autoload.php file we've provided.

UUID v4

This is the fastest and easiest to use, as it has no configuration options. The probability of a collission is microscopic. The number of different combinations is approximately 5,3169e+36.

If collisions happen, it is because of bugs in the generator. The ramsay If you've heard that collisions happen, you can be quite certain that the collision happened because of using an inferior random number generator.

Quotes from around the web:

| If you generate 103 trillion UUID v4, the probability of a collision is about 1 in a billion.

| If you have a database of 1 petabyte of UUIDs, the probability of a single collision is | one in 50 billion.

| If you generate 8 billion UUIDs per second,

`

UUID v1

This UUID is guaranteed to be unique, provided you have a unique machine ID - for example using a MAC address.

Service Object API

Static API

Configuration:

Configuration is done via the IdFactory constructor, or the Id::configure() method. For up-to-date configuration options, see the IdFactory source file.

Comparison:

Snowflake and variants are usually sufficient for any internal ID scheme up to Twitter or Instagram scale. UUIDs are by many considered to be too large to be used extensively internally in a database - but are very useful to generate unique IDs for APIs or for allowing external clients to generate IDs offline.


All versions of uuid with dependencies

PHP Build Version
Package Version
No informations.
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package charm/uuid contains the following files

Loading the files please wait ....