PHPackages                             munix/munix - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. munix/munix

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

munix/munix
===========

A Unique ID (64-bit Integer) Generator For PHP

v0.0.5(3y ago)19MITPHPPHP &gt;=7.0.0

Since Aug 30Pushed 2y ago1 watchersCompare

[ Source](https://github.com/phrenotype/munix)[ Packagist](https://packagist.org/packages/munix/munix)[ RSS](/packages/munix-munix/feed)WikiDiscussions main Synced yesterday

READMEChangelog (5)DependenciesVersions (6)Used By (0)

Munix : A Unique ID Generator
=============================

[](#munix--a-unique-id-generator)

A unique random id generator that produces unique signed 64 bit integers without the need for a dedicated id server. The generated id's can be used as unique identifiers for objects. Collisions are guaranteed not to occur. This was built to run on one or several machines that accept multiple requests per second.

Install
=======

[](#install)

`composer install munix/munix`

Requirements
============

[](#requirements)

Munix requires `sqlite` to be installed and enabled in `php.ini`. A small sqlite db it used to track number sequences within milliseconds of each other to prevent collisions. Yes, it's small. It just contains one table, one column, and one row (1 x 1).

Usage
=====

[](#usage)

To get an id, you only need to call one method, `Munix\Munix::nextId(int $customId)`.

The only thing needed is a custom number from 0 (inclusive) to 1023 (inclusive). For a single project, any number in that range will suffice. However, if it's a distributed system, each machine will need a different number, to avoid collisions.

If no `custom id` is supplied, the default value of `0` is used.

```
