PHPackages                             jewei/typeid-php - 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. jewei/typeid-php

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

jewei/typeid-php
================

PHP implementation of TypeID specification: type-safe, K-sortable, and globally unique identifiers inspired by Stripe IDs

v1.1.5(2mo ago)87.6k↑26.4%1MITPHPPHP ^8.4.0CI passing

Since Apr 25Pushed 2mo ago1 watchersCompare

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

READMEChangelog (10)Dependencies (8)Versions (11)Used By (1)

 [![Build Status](https://github.com/jewei/typeid-php/actions/workflows/tests.yml/badge.svg)](https://github.com/jewei/typeid-php/actions) [![Total Downloads](https://camo.githubusercontent.com/8605bf97529057966c1fa4e5e9b7568dc7cb6b8acc15b1a6c493c9a03dcc2f9d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6a657765692f7479706569642d706870)](https://packagist.org/packages/jewei/typeid-php) [![Latest Stable Version](https://camo.githubusercontent.com/9c9483f6482375cdc54c12b4d6b0da04ed59a5c3d39dafa6816659ca8a8c751d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6a657765692f7479706569642d706870)](https://packagist.org/packages/jewei/typeid-php) [![License](https://camo.githubusercontent.com/1c622865334dbb27261555b2b82a2aa182d29b20b5b1f526bf9bcf665297efdf/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6a657765692f7479706569642d706870)](https://packagist.org/packages/jewei/typeid-php)

TypeID PHP
==========

[](#typeid-php)

A PHP 8.4 implementation of [TypeIDs](https://github.com/jetify-com/typeid): type-safe, K-sortable, globally-unique identifiers inspired by Stripe IDs.

TypeIDs extend UUIDv7 with a type prefix, giving you better ergonomics for database IDs, API resources, and distributed systems.

Features
--------

[](#features)

- **Type-safe** — prefix encodes the entity type, preventing ID mix-ups across types
- **K-sortable** — UUIDv7 timestamp in the high bits means IDs sort chronologically
- **Compact** — 26-char Crockford base32 suffix vs 36 chars for a standard UUID string
- **URL-safe** — only `[a-z0-9_]` characters, no encoding needed
- **Zero dependencies** — pure bit manipulation, no GMP or bcmath required

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

[](#requirements)

- PHP 8.4+

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

[](#installation)

```
composer require jewei/typeid-php
```

Usage
-----

[](#usage)

```
use TypeID\TypeID;

// Generate a new K-sortable TypeID
$id = TypeID::generate('user');
echo $id;          // user_01jsnsf2g7e2saxdjvz3j6tc3x
echo $id->prefix;  // user
echo $id->suffix;  // 01jsnsf2g7e2saxdjvz3j6tc3x
echo $id->toUuid(); // 01966b97-8a07-70b2-aeb6-5bf8e46d307d

// Parse from a string
$id = TypeID::fromString('user_01jsnsf2g7e2saxdjvz3j6tc3x');
echo $id->prefix;  // user

// Encode an existing UUID
$id = TypeID::fromUuid('01966b97-8a07-70b2-aeb6-5bf8e46d307d', 'invoice');
echo $id; // invoice_01jsnsf2g7e2saxdjvz3j6tc3x

// Zero/nil TypeID — useful as a sentinel value
$zero = TypeID::zero('user');
echo $zero->isZero(); // true

// Equality check
$a = TypeID::fromString('user_01jsnsf2g7e2saxdjvz3j6tc3x');
$b = TypeID::fromString('user_01jsnsf2g7e2saxdjvz3j6tc3x');
echo $a->equals($b); // true
```

Format
------

[](#format)

```
user_01jsnsf2g7e2saxdjvz3j6tc3x
^^^^  ^^^^^^^^^^^^^^^^^^^^^^^^^^
│     └─ 26-char Crockford base32 (encodes a 128-bit UUIDv7)
└─ prefix: lowercase entity type label (0–63 chars)

```

The prefix is separated from the suffix by `_`. When no prefix is used, the TypeID is just the bare 26-char suffix. Multiple underscores are allowed in the prefix (`post_category_01jsnsf2g7…`); the last underscore is always the delimiter.

Examples
--------

[](#examples)

TypeIDPrefixSuffix`01jsnsf2g7e2saxdjvz3j6tc3x`*(none)*01jsnsf2g7e2saxdjvz3j6tc3x`user_01jsnsf2g7e2saxdjvz3j6tc3x`user01jsnsf2g7e2saxdjvz3j6tc3x`post_category_01jsnsf2g7e2saxdjvz3j6tc3x`post\_category01jsnsf2g7e2saxdjvz3j6tc3xTesting
-------

[](#testing)

```
composer test
```

###  Health Score

51

—

FairBetter than 96% of packages

Maintenance88

Actively maintained with recent releases

Popularity31

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity61

Established project with proven stability

 Bus Factor1

Top contributor holds 100% 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 ~36 days

Recently: every ~0 days

Total

10

Last Release

60d ago

PHP version history (3 changes)v1.0.0PHP ^8.2.0

v1.1.0PHP ^8.3.0

v1.1.1PHP ^8.4.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/eff2aae75fedc33424e4b054f48583b422e795e233ce065ba9a385a08bbeac86?d=identicon)[jewei](/maintainers/jewei)

---

Top Contributors

[![jewei](https://avatars.githubusercontent.com/u/51693?v=4)](https://github.com/jewei "jewei (26 commits)")

---

Tags

uuididentifiertype-safetypeidstripe-idsk-sortable

###  Code Quality

TestsPest

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/jewei-typeid-php/health.svg)

```
[![Health](https://phpackages.com/badges/jewei-typeid-php/health.svg)](https://phpackages.com/packages/jewei-typeid-php)
```

###  Alternatives

[ramsey/uuid

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

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

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

5951.8M15](/packages/pascaldevink-shortuuid)[keiko/uuid-shortener

A simple shortener library for RFC 4122 compatible UUIDs. Change your 36 chars long UUID into it's shorter equivalent.

150215.4k2](/packages/keiko-uuid-shortener)[oittaa/uuid

A small PHP class for generating RFC 9562 universally unique identifiers (UUID) from version 3 to version 8.

50302.7k5](/packages/oittaa-uuid)[ekreative/uuid-extra-bundle

Paramconverter, Normalizer and Form Type for Ramsey Uuid

18168.6k](/packages/ekreative-uuid-extra-bundle)[pyyoshi/shortuuid-php

2226.1k](/packages/pyyoshi-shortuuid-php)

PHPackages © 2026

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