Download the PHP package mediagone/small-uid without Composer

On this page you can find all versions of the php package mediagone/small-uid. 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 small-uid

Small UID

⚠️ This project is in experimental phase, the API may may be subject to change.

Latest Version on Packagist Total Downloads

UUIDs are frequently used as database Primary Key in software development. However, they aren't the best choice mainly due to their random sorting and the resulting fragmentation in databases indexes.

Using ULIDs is generally a very good alternative, solving most of UUID flaws.

Small UIDs are also an ideal alternative when you do not need as much uniqueness and want shorter "user-friendly" encoded strings.

Introduction

Small UIDs are short unique identifiers especially designed to be used as efficient database Primary Key:

Small UID ULID UUID v4
Size 64 bits 128 bits 128 bits
Monotonic sort order Yes *** Yes No
Random bits 20 80 122
Collision odds ** 1,024 / ms* 1.099e+12 / ms* 2.305e+18

* theorical number of generated uids before the first expected collision.\ ** the uid includes a timestamp, so collisions may occur only during the same millisecond.\ *** monotonic sort order, but random order when generated at the same millisecond.

They are internally stored as 64-bit integers (44-bit timestamp followed by 20 random bits):

|-----------------------|  |------------|
        Timestamp            Randomness
         44 bits               20 bits

The random number suffix still guarantees a decent amount of uniqueness when many ids are created in the same millisecond (up to 1,048,576 different values) and you may only expect collision if you're generating more than 1024 random ids during the same millisecond.

Sorting

Because of the sequential timestamp, Small UIDs are naturally sorted chronologically. It improves indexing when inserting values in databases, new ids being appended to the end of the table without reshuffling existing data (read more in this article).

However, sort order within the same millisecond is not guaranteed because of the random bits suffix.

Installation

This package requires PHP (64-bit) 7.4+ and GMP extension.

Add it as Composer dependency:

If you're using Doctrine ORM, you'll probably want to install also appropriate custom types:

Examples of usage

Generating Small UIDs

Converting Small UIDs

License

Small UID is licensed under MIT license. See LICENSE file.


All versions of small-uid with dependencies

PHP Build Version
Package Version
Requires php-64bit Version ^7.4|^8.0
ext-gmp Version *
mediagone/types-common Version ^0.5.1|^0.6
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 mediagone/small-uid contains the following files

Loading the files please wait ....