PHPackages                             guanhui07/sqids - 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. guanhui07/sqids

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

guanhui07/sqids
===============

Generate short YouTube-looking IDs from numbers

0.5.0(1y ago)015MITPHPPHP ^7.1

Since Jul 29Pushed 1y agoCompare

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

READMEChangelog (1)DependenciesVersions (10)Used By (0)

[Sqids PHP](https://sqids.org/php)
==================================

[](#sqids-php)

[![Latest Version](https://camo.githubusercontent.com/a123ef9ef0454abf3c028a91035df8a48d101d0dc6dbe3b12dafa11ec04546f0/68747470733a2f2f62616467656e2e6e65742f7061636b61676973742f762f73716964732f7371696473)](https://packagist.org/packages/sqids/sqids)[![Build Status](https://camo.githubusercontent.com/039994e83cde1dc4a974f1a7b66990f8746766aaf2b214373d3ef12f4dc3a510/68747470733a2f2f62616467656e2e6e65742f6769746875622f636865636b732f73716964732f73716964732d7068703f6c6162656c3d6275696c642669636f6e3d676974687562)](https://github.com/sqids/sqids-php/actions)[![Monthly Downloads](https://camo.githubusercontent.com/2dde7d02b946e3feca9e457ca3fc52151c507ba4ad110284472beda3c91a6c05/68747470733a2f2f62616467656e2e6e65742f7061636b61676973742f646d2f73716964732f7371696473)](https://packagist.org/packages/sqids/sqids/stats)

[Sqids](https://sqids.org/php) (*pronounced "squids"*) is a small library that lets you **generate unique IDs from numbers**. It's good for link shortening, fast &amp; URL-safe ID generation and decoding back into numbers for quicker database lookups.

Features:

- **Encode multiple numbers** - generate short IDs from one or several non-negative numbers
- **Quick decoding** - easily decode IDs back into numbers
- **Unique IDs** - generate unique IDs by shuffling the alphabet once
- **ID padding** - provide minimum length to make IDs more uniform
- **URL safe** - auto-generated IDs do not contain common profanity
- **Randomized output** - Sequential input provides nonconsecutive IDs
- **Many implementations** - Support for [40+ programming languages](https://sqids.org/)

🧰 Use-cases
-----------

[](#-use-cases)

Good for:

- Generating IDs for public URLs (eg: link shortening)
- Generating IDs for internal systems (eg: event tracking)
- Decoding for quicker database lookups (eg: by primary keys)

Not good for:

- Sensitive data (this is not an encryption library)
- User IDs (can be decoded revealing user count)

🚀 Getting started
-----------------

[](#-getting-started)

Require this package, with [Composer](https://getcomposer.org), in the root directory of your project.

```
composer require guanhui07/sqids
```

Then you can import the class into your application:

```
use Sqids\Sqids;
$sqids = new Sqids();
```

Important

Sqids require either the [`bcmath`](https://secure.php.net/manual/en/book.bc.php) or [`gmp`](https://secure.php.net/manual/en/book.gmp.php) extension in order to work.

👩‍💻 Examples
------------

[](#‍-examples)

Simple encode &amp; decode:

```
$sqids = new Sqids();
$id = $sqids->encode([1, 2, 3]); // "86Rf07"
$numbers = $sqids->decode($id); // [1, 2, 3]
```

Note

🚧 Because of the algorithm's design, **multiple IDs can decode back into the same sequence of numbers**. If it's important to your design that IDs are canonical, you have to manually re-encode decoded numbers and check that the generated ID matches.

Enforce a *minimum* length for IDs:

```
$sqids = new Sqids(minLength: 10);
$id = $sqids->encode([1, 2, 3]); // "86Rf07xd4z"
$numbers = $sqids->decode($id); // [1, 2, 3]
```

Randomize IDs by providing a custom alphabet:

```
$sqids = new Sqids(alphabet: 'FxnXM1kBN6cuhsAvjW3Co7l2RePyY8DwaU04Tzt9fHQrqSVKdpimLGIJOgb5ZE');
$id = $sqids->encode([1, 2, 3]); // "B4aajs"
$numbers = $sqids->decode($id); // [1, 2, 3]
```

Prevent specific words from appearing anywhere in the auto-generated IDs:

```
$sqids = new Sqids(blocklist: ['86Rf07']);
$id = $sqids->encode([1, 2, 3]); // "se8ojk"
$numbers = $sqids->decode($id); // [1, 2, 3]
```

📝 License
---------

[](#-license)

[MIT](LICENSE)

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance37

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity34

Early-stage or recently created project

 Bus Factor1

Top contributor holds 50% 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 ~60 days

Recently: every ~102 days

Total

8

Last Release

593d ago

PHP version history (3 changes)0.0.1PHP ^8.2

0.4.1PHP ^8.1

0.5.0PHP ^7.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/3abde3fccf025ce86670101d7cfa0641d2415c9daad93e5f0c9573a2b23ddbda?d=identicon)[guanhui07](/maintainers/guanhui07)

---

Top Contributors

[![vinkla](https://avatars.githubusercontent.com/u/499192?v=4)](https://github.com/vinkla "vinkla (24 commits)")[![4kimov](https://avatars.githubusercontent.com/u/56128128?v=4)](https://github.com/4kimov "4kimov (19 commits)")[![guanhui07](https://avatars.githubusercontent.com/u/5820457?v=4)](https://github.com/guanhui07 "guanhui07 (5 commits)")

---

Tags

encodedecodeidshashidsgeneratesqids

### Embed Badge

![Health badge](/badges/guanhui07-sqids/health.svg)

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

###  Alternatives

[hashids/hashids

Generate short, unique, non-sequential ids (like YouTube and Bitly) from numbers

5.5k48.6M275](/packages/hashids-hashids)[sqids/sqids

Generate short YouTube-looking IDs from numbers

5781.4M33](/packages/sqids-sqids)[jenssegers/optimus

Id obfuscation based on Knuth's integer hash method

1.3k4.8M27](/packages/jenssegers-optimus)[christian-riesen/base32

Base32 encoder/decoder according to RFC 4648

13331.8M60](/packages/christian-riesen-base32)[delight-im/ids

Short, obfuscated and efficient IDs for PHP

289.5k1](/packages/delight-im-ids)[torann/hashids

Laravel package for Hashids

54335.1k](/packages/torann-hashids)

PHPackages © 2026

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