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

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

odan/tsid
=========

A library for generating Time Sortable Identifiers (TSID).

0.2.0(3mo ago)25229.8k—4.8%6MITPHPPHP 8.2.\* || 8.3.\* || 8.4.\* || 8.5.\*CI passing

Since Dec 9Pushed 3mo ago1 watchersCompare

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

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

TSID – Time-Sorted Unique Identifiers
=====================================

[](#tsid--time-sorted-unique-identifiers)

[![Latest Version on Packagist](https://camo.githubusercontent.com/45458335d63955ab53edf8891aea96fe4340b0202165a6a07110cd484ffedacf/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f6f64616e2f747369642e737667)](https://packagist.org/packages/odan/tsid)[![Software License](https://camo.githubusercontent.com/074b89bca64d3edc93a1db6c7e3b1636b874540ba91d66367c0e5e354c56d0ea/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e737667)](LICENSE)[![Build Status](https://github.com/odan/tsid/workflows/build/badge.svg)](https://github.com/odan/tsid/actions)[![Total Downloads](https://camo.githubusercontent.com/0e4e6b2e48b1943028cc2d9543bdcf873320026ce60889d50ee8d323ade31745/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6f64616e2f747369642e737667)](https://packagist.org/packages/odan/tsid/stats)

Description
-----------

[](#description)

A library for generating Time Sortable Identifiers (TSID).

This library is a port of [TSID Creator](https://github.com/f4b6a3/tsid-creator) from Java to PHP.

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

[](#requirements)

- PHP 8.2+

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

[](#installation)

```
composer require odan/tsid

```

Usage
-----

[](#usage)

```
use Odan\Tsid\TsidFactory;

$tsidFactory = new TsidFactory();

$tsid = $tsidFactory->generate();

// 388400145978465528
echo $tsid->toInt();

// 0ARYZVZXW377R
echo $tsid->toString();
```

Database Usage
--------------

[](#database-usage)

### MySQL

[](#mysql)

Use `bigint(20) unsigned` as datatype for the (primary / secondary) key.

Example:

```
CREATE TABLE `users` (
    `id` bigint(20) unsigned NOT NULL,
    `username` varchar(45) NOT NULL,
     PRIMARY KEY (`id`)
) ENGINE=InnoDB
```

**Note:** When you use `BIGINT(20)` the maximum value is 2^63 - 1 == `9223372036854775807`. This means there is still enough space to store any TSID. When you use `BIGINT(20) unsigned` the maximum value is: 2^64-1 = `18446744073709551615`

### SQLite

[](#sqlite)

Use `INTEGER` as datatype for the (primary / secondary) key.

```
CREATE TABLE users (id INTEGER PRIMARY KEY, username TEXT);
```

**Note:** SQLite uses an 8-byte **signed** integer to store integers. So the maximum positive integer value is 2^63 - 1 == `9223372036854775807`. This means there is still enough space to store any TSID.

Data Type Comparison
--------------------

[](#data-type-comparison)

```
TSID max:                          18446744073709551615
TSID 2023-01-01T00:00:00.000Z:       397177100698290050
TSID 2038-01-19T03:14:07.000Z:      2389272048961164191
TSID 2999-12-31T23:59:59.999Z:      7015104302283010234
PHP_INT_MAX:                        9223372036854775807
SQLite INTEGER max:                 9223372036854775807
MySQL BIGINT(20) max:               9223372036854775807
MySQL BIGINT(20) unsigned max:     18446744073709551615

```

Read more
---------

[](#read-more)

-
-
- [UUID version 7](https://symfony.com/doc/current/components/uid.html#generating-uuids) features a time-ordered value field.
- [ULID's](https://symfony.com/doc/current/components/uid.html#ulids) are 128-bit numbers with a timestamp and random bits.

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE) for more information.

###  Health Score

52

—

FairBetter than 96% of packages

Maintenance81

Actively maintained with recent releases

Popularity45

Moderate usage in the ecosystem

Community12

Small or concentrated contributor base

Maturity55

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 92.9% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~1154 days

Total

2

Last Release

102d ago

PHP version history (2 changes)0.1.0PHP ^8

0.2.0PHP 8.2.\* || 8.3.\* || 8.4.\* || 8.5.\*

### Community

Maintainers

![](https://www.gravatar.com/avatar/89d408d7f6ed65cdbeba70a2da2d0a8a1135fc37ebc07c44989f509221cc91bd?d=identicon)[odan](/maintainers/odan)

---

Top Contributors

[![odan](https://avatars.githubusercontent.com/u/781074?v=4)](https://github.com/odan "odan (13 commits)")[![jspetrak](https://avatars.githubusercontent.com/u/146057?v=4)](https://github.com/jspetrak "jspetrak (1 commits)")

---

Tags

uuidtsid

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/odan-tsid/health.svg)

```
[![Health](https://phpackages.com/badges/odan-tsid/health.svg)](https://phpackages.com/packages/odan-tsid)
```

###  Alternatives

[ramsey/uuid

A PHP library for generating and working with universally unique identifiers (UUIDs).

12.6k700.2M3.3k](/packages/ramsey-uuid)[symfony/polyfill-uuid

Symfony polyfill for uuid functions

690335.4M63](/packages/symfony-polyfill-uuid)[symfony/uid

Provides an object-oriented API to generate and represent UIDs

610280.0M754](/packages/symfony-uid)[webpatser/laravel-uuid

Laravel integration for webpatser/uuid - High-performance drop-in UUID replacements (15% faster than Ramsey). Provides Str macros, HasUuids trait, facades, and casts. RFC 4122/9562 compliant.

1.8k17.3M129](/packages/webpatser-laravel-uuid)[pascaldevink/shortuuid

PHP 7.4+ library that generates concise, unambiguous, URL-safe UUIDs

5951.8M15](/packages/pascaldevink-shortuuid)[emadadly/laravel-uuid

laravel uuid a simple, automatic UUID generator for any model based on Laravel.

120415.9k3](/packages/emadadly-laravel-uuid)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
