PHPackages                             antikirra/tsid - 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. antikirra/tsid

ActiveLibrary

antikirra/tsid
==============

3.1.0(7mo ago)2457MITPHPPHP ^5.6 || ^7.0 || ^8.0

Since May 24Pushed 7mo ago1 watchersCompare

[ Source](https://github.com/antikirra/tsid)[ Packagist](https://packagist.org/packages/antikirra/tsid)[ RSS](/packages/antikirra-tsid/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (1)Versions (8)Used By (0)

TSID | TimeStampable IDentifier
===============================

[](#tsid--timestampable-identifier)

[![Packagist Dependency Version](https://camo.githubusercontent.com/7b4c1ccc24f185ea91cde20d49ea0b733bf05be5326f5a240134378285394117/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646570656e64656e63792d762f616e74696b697272612f747369642f706870)](https://camo.githubusercontent.com/7b4c1ccc24f185ea91cde20d49ea0b733bf05be5326f5a240134378285394117/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646570656e64656e63792d762f616e74696b697272612f747369642f706870)[![Packagist Version](https://camo.githubusercontent.com/3a198d9c31eee36ecf46d83f4cc1697d913f7ca1e5d21eb200eb5c60951a6109/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f616e74696b697272612f74736964)](https://camo.githubusercontent.com/3a198d9c31eee36ecf46d83f4cc1697d913f7ca1e5d21eb200eb5c60951a6109/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f616e74696b697272612f74736964)[![Code Coverage](https://camo.githubusercontent.com/32855e94577df9d0a30995653b17d33a5fbfdf644518f96ea0374313397d19b7/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f636f7665726167652d3130302532352d627269676874677265656e)](https://camo.githubusercontent.com/32855e94577df9d0a30995653b17d33a5fbfdf644518f96ea0374313397d19b7/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f636f7665726167652d3130302532352d627269676874677265656e)

**Ultra-fast, lightweight PHP library for generating unique timestamp-based identifiers with nanosecond precision.** Perfect for distributed systems, high-throughput applications, and scenarios requiring guaranteed unique ID generation without external dependencies.

Install
-------

[](#install)

```
composer require antikirra/tsid:^3.0
```

Why TSID?
---------

[](#why-tsid)

- ✨ **Blazing Fast Performance** - Zero dependencies, minimal overhead, optimized for speed
- 🔧 **Universal Compatibility** - Works seamlessly from PHP 5.6 to PHP 8.4+
- ⚡ **Nanosecond Precision** - Guaranteed uniqueness even in high-frequency generation
- 🎯 **Snowflake Alternative** - Simple, efficient replacement for complex ID generators
- 📦 **Lightweight** - Compact, pure PHP implementation with no bloat
- 🚀 **Production Ready** - Battle-tested in high-load distributed environments

Features
--------

[](#features)

- **High-Performance ID Generation**: Up to 39M+ unique IDs per second (Apple M4, PHP 8.4)
- **Timestamp-Based**: IDs contain creation time information for easy sorting and analysis
- **Strictly Monotonic**: Guarantees each ID is always greater than the previous, even during clock adjustments
- **Collision-Free**: Mathematical guarantee of uniqueness within single process
- **Memory Efficient**: Minimal memory footprint, perfect for microservices
- **Legacy Support**: Compatible with ancient PHP versions (5.6+) and modern PHP 8.4
- **Zero Dependencies**: No external libraries, frameworks, or extensions required
- **Process-Safe**: Safe for use in single-threaded PHP processes with static state management
- **100% Test Coverage**: Fully tested with 42 test cases and 5,781 assertions

Perfect for
-----------

[](#perfect-for)

- **Distributed Systems**: Unique ID generation across multiple servers
- **High-Frequency APIs**: REST APIs, microservices, real-time applications
- **Database Primary Keys**: Alternative to auto-increment IDs in sharded databases
- **Logging &amp; Tracing**: Unique request IDs, transaction tracking
- **Message Queues**: Job IDs, task identifiers in queue systems
- **Legacy Systems**: Drop-in solution for old PHP applications requiring unique IDs

Requirements
------------

[](#requirements)

- **PHP**: 5.6 or higher
- **Extensions**: None (uses only core PHP functions)
- **Memory**: Minimal (&lt; 1MB)
- **Dependencies**: Zero

Basic usage
-----------

[](#basic-usage)

```
