PHPackages                             jordimorillo/uid - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. jordimorillo/uid

ActiveLibrary[Database &amp; ORM](/categories/database)

jordimorillo/uid
================

A package to self-generate 32bit unique integer identifiers that can be used as primary keys in relational databases

1.0.4(2y ago)014GPL-3.0-onlyPHP

Since Feb 21Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/jordimorillo/uid)[ Packagist](https://packagist.org/packages/jordimorillo/uid)[ RSS](/packages/jordimorillo-uid/feed)WikiDiscussions master Synced 1w ago

READMEChangelog (5)Dependencies (3)Versions (7)Used By (0)

Unique Integer Identifiers for PHP
==================================

[](#unique-integer-identifiers-for-php)

The goal for this package is:

- To provide unique identifiers.
- The identifiers will be integer so they can be used as primary keys in relational databases to keep performance.
- Do not depend on third services to generate the Ids as happens with workers.
- The generated identifier will be 32 bytes.

The current formula is:

UniqueId = `php-object-identifier` + `random-integer` + `microtime`

To this identifier gets repeated it should coincide the object identifier, the microtime, and a 7 number random integer. That is really very improbable but may happen in very rare ocasion.

Example of use:

```
