PHPackages                             pyyoshi/shortuuid-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. pyyoshi/shortuuid-php

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

pyyoshi/shortuuid-php
=====================

1.0.7(8y ago)2226.1k↓100%8[1 issues](https://github.com/PyYoshi/shortuuid-php/issues)BSDPHPPHP &gt;=5.6

Since Feb 11Pushed 5y ago1 watchersCompare

[ Source](https://github.com/PyYoshi/shortuuid-php)[ Packagist](https://packagist.org/packages/pyyoshi/shortuuid-php)[ Docs](https://github.com/PyYoshi/shortuuid-php)[ RSS](/packages/pyyoshi-shortuuid-php/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (3)Versions (9)Used By (0)

shortuuid-php
=============

[](#shortuuid-php)

[![Build Status](https://camo.githubusercontent.com/16767c93b81dc5f8650120df18e5064be70ca9dc731b314c66b56538cc113340/68747470733a2f2f7472617669732d63692e6f72672f5079596f7368692f73686f7274757569642d7068702e737667)](https://travis-ci.org/PyYoshi/shortuuid-php)[![Build Status](https://camo.githubusercontent.com/f4de33c08564279fa7ea5b55618ae5d57c91696f89fc1bd2f5f11f579f4bf6ae/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f5079596f7368692f73686f7274757569642d7068702e737667)](https://packagist.org/packages/pyyoshi/shortuuid-php)

The PHP implementation of [shortuuid](https://github.com/stochastic-technologies/shortuuid).

Installation
============

[](#installation)

```
composer require pyyoshi/shortuuid-php
```

or add this library in your `composer.json`

```
{
    "require": {
        "pyyoshi/shortuuid-php": "*"
    }
}
```

Usage
=====

[](#usage)

import

```
require dirname(__DIR__) . "/vendor/autoload.php";
require_once 'ShortUUID/Autoloader.php';
\ShortUUID\Autoloader::register();
```

You can then generate a short UUID:

```
use ShortUUID\ShortUUID;

$su = new ShortUUID();
$su->uuid();
=> "rkQdp5ikpXjraCsrSaysaT"
```

If you prefer a version 5 UUID, you can pass a name (DNS or URL) to the call and it will be used as a namespace (uuid.NAMESPACE\_DNS or uuid.NAMESPACE\_URL) for the resulting UUID:

```
use ShortUUID\ShortUUID;

$su = new ShortUUID();
$su->uuid('example.com');
=> "wpsWLdLt9nscn2jbTD3uxe"
$su->uuid('http://www.example.com/');
=> "VSPugLzk4dD4WC7yfAQUzn"
```

To see the alphabet that is being used to generate new UUIDs:

```
use ShortUUID\ShortUUID;

$su = new ShortUUID();
$su->getAlphabet();
=> "23456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"
```

If you want to use your own alphabet to generate UUIDs, use setAlphabet():

```
use ShortUUID\ShortUUID;

$su = new ShortUUID();
$su->setAlphabet('aaaaabcdefgh1230123');
$su->uuid();
=> "ee120aeh2h3bb010fdfedef2c03efcf3h1ca"
```

`shortuuid-php` will automatically sort and remove duplicates from your alphabet to ensure consistency:

```
use ShortUUID\ShortUUID;

$su = new ShortUUID();
$su->setAlphabet('aaaaabcdefgh1230123');
$su->getAlphabet();
=> "0123abcdefgh"
```

If the default 22 digits are too long for you, you can get shorter IDs by just truncating the string to the desired length. The IDs won't be universally unique any longer, but the probability of a collision will still be very low.

To serialize existing UUIDs, use encode() and decode():

```
use Ramsey\Uuid\Uuid;
use ShortUUID\ShortUUID;

$u = Uuid::uuid4();
$su = new ShortUUID();
$s = $su->encode($u);

$su->decode($s) == $u;
=> true
```

License
=======

[](#license)

`shortuuid-php` is distributed under the BSD license.

###  Health Score

37

—

LowBetter than 84% of packages

Maintenance19

Infrequent updates — may be unmaintained

Popularity36

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor1

Top contributor holds 72.7% 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 ~147 days

Recently: every ~196 days

Total

8

Last Release

3028d ago

PHP version history (3 changes)1.0.0PHP &gt;=5.3

1.0.3PHP &gt;=5.5

1.0.6PHP &gt;=5.6

### Community

Maintainers

![](https://www.gravatar.com/avatar/376e5f7f7709f89069949d73b4b35a358e49a5428d2e4e3b18503e7d80224411?d=identicon)[PyYoshi](/maintainers/PyYoshi)

---

Top Contributors

[![PyYoshi](https://avatars.githubusercontent.com/u/467255?v=4)](https://github.com/PyYoshi "PyYoshi (16 commits)")[![adriankeenan](https://avatars.githubusercontent.com/u/4071397?v=4)](https://github.com/adriankeenan "adriankeenan (3 commits)")[![Hipio](https://avatars.githubusercontent.com/u/124501889?v=4)](https://github.com/Hipio "Hipio (2 commits)")[![inoas](https://avatars.githubusercontent.com/u/20972207?v=4)](https://github.com/inoas "inoas (1 commits)")

---

Tags

uuididentifierguid

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/pyyoshi-shortuuid-php/health.svg)

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

###  Alternatives

[ramsey/uuid

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

12.6k686.5M2.9k](/packages/ramsey-uuid)[pascaldevink/shortuuid

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

5951.8M14](/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.

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

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

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

Paramconverter, Normalizer and Form Type for Ramsey Uuid

18168.1k](/packages/ekreative-uuid-extra-bundle)[thamtech/yii2-uuid

Yii 2 UUID Helper

35341.5k7](/packages/thamtech-yii2-uuid)

PHPackages © 2026

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