PHPackages                             ndtan/id-generator-lite - 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. ndtan/id-generator-lite

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

ndtan/id-generator-lite
=======================

NDT ID Generator — Lite: single-file, dependency-free PHP ID generator (UUID v4/v7, ULID, NanoID, Mongo ObjectId, ShortUUID, KSUID, Snowflake).

v0.1.0(9mo ago)02MITPHPPHP &gt;=8.1CI passing

Since Sep 21Pushed 9mo agoCompare

[ Source](https://github.com/nguyenduytan/NDT-ID-Generator-Lite)[ Packagist](https://packagist.org/packages/ndtan/id-generator-lite)[ RSS](/packages/ndtan-id-generator-lite/feed)WikiDiscussions main Synced today

READMEChangelog (1)Dependencies (1)Versions (2)Used By (0)

NDT ID Generator — Lite
=======================

[](#ndt-id-generator--lite)

> Single‑file, dependency‑free PHP library for generating **UUID v4/v7**, **ULID**, **NanoID**, **Mongo ObjectId**, **ShortUUID (Base58)**, **KSUID (Base62)**, and **Snowflake**.
> Namespace: `ndtan` · PHP 8.1+ · PSR‑4 autoload

 [![PHP](https://camo.githubusercontent.com/3e41095f4ad1c6ad78f988bd1c107f87972f334143c3ba814165a03e1f43a63c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e312532422d3737374242343f6c6f676f3d706870266c6f676f436f6c6f723d7768697465)](https://camo.githubusercontent.com/3e41095f4ad1c6ad78f988bd1c107f87972f334143c3ba814165a03e1f43a63c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e312532422d3737374242343f6c6f676f3d706870266c6f676f436f6c6f723d7768697465) [![License](https://camo.githubusercontent.com/5caa455d8debc46fb23abbadb45a733a937f3910a73fc875c2f7820468e1bb54/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d677265656e)](https://camo.githubusercontent.com/5caa455d8debc46fb23abbadb45a733a937f3910a73fc875c2f7820468e1bb54/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d677265656e) [![Type](https://camo.githubusercontent.com/4be6174f660c503479ec791bf5b7bba347e1d9aed3d91caaedf30807a77b3247/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f53696e676c6525323066696c652d494425323047656e657261746f72732d626c7565)](https://camo.githubusercontent.com/4be6174f660c503479ec791bf5b7bba347e1d9aed3d91caaedf30807a77b3247/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f53696e676c6525323066696c652d494425323047656e657261746f72732d626c7565)

---

Table of Contents
-----------------

[](#table-of-contents)

- [Features](#features)
- [Installation](#installation)
- [Quick Start](#quick-start)
- [API Reference](#api-reference)
- [Snowflake Configuration (optional)](#snowflake-configuration-optional)
- [Which ID should I use?](#which-id-should-i-use)
- [Notes &amp; Guarantees](#notes--guarantees)
- [Testing](#testing)
- [Changelog](#changelog)
- [License](#license)

---

Features
--------

[](#features)

- ✅ **Single file** core: `src/ID.php`
- ✅ **No external dependencies** (pure PHP)
- ✅ **UUID v4** (random), **UUID v7** (time‑ordered; RFC 9562)
- ✅ **ULID** (Crockford Base32) + **monotonic** variant
- ✅ **NanoID** (URL‑safe; customizable length/alphabet)
- ✅ **Mongo ObjectId** (24 hex chars)
- ✅ **ShortUUID** (UUID → Base58)
- ✅ **KSUID** (27 chars, Base62, time‑ordered)
- ✅ **Snowflake** (64‑bit; string return for 32‑bit safety)
- ✅ Works with **any framework** (Composer autoload) and plain PHP

---

Installation
------------

[](#installation)

```
composer require ndtan/id-generator-lite
```

> Requires PHP **8.1+** and the `random_bytes()` function available by default.

---

Quick Start
-----------

[](#quick-start)

```
