Hashids / PHP + Rust

Hide numeric IDsbehind short codes

Short code encoding, multiple connections and six framework adapters on a core with no framework dependency.

Hashy the square mascot, the hashids project pet

One core, six ways in

The core only resolves multiple connections and builds instances, with no framework dependency; connection() builds and caches on demand, and __call() forwards to the default connection.

The six framework adapters total about 490 lines and only handle container binding and config loading; the Laravel Facade and config format match vinkla/hashids.

  • Multiple connections
  • encode / decode
  • Container bindings
6Framework adapters
v1.3.0Current version
12Language translations
Hashy the square mascot Smile expression

Hashy

A rounded square teal creature with an antenna, a # badge on its chest, and a speech bubble showing the encoded result 3kTMd.

Turn numeric IDs into short codes.

Encoding to wiring

Six groups around one framework-free core.

Short code encoding

encode, decode and hex variants reach the default connection through __call().

Multiple connections

Configure Salt and Length per connection; connection() switches, builds once and caches.

Six framework adapters

Native wiring for Laravel, Webman, ThinkPHP, Hyperf, Yii 2 and Yii 3.

vinkla alignment

Facade, container bindings and config shape match vinkla/hashids for a smooth swap.

Zero framework deps

The core only needs hashids/hashids; new HashidsManager works standalone.

Twelve translations

The README and architecture diagrams ship in 12 translations.

Same capability, Rust version

Beyond PHP, the same short ID capability is available as a native Rust implementation.

Rust v2.0.0 Rust 1.85 / crate

hashids-rust

Native Rust short IDs

Native hashids with official test vectors, zero default deps and eight Rust web frameworks.

  • Official test vectors
  • Zero default deps
  • Eight web frameworks
View Rust repository

How the features grew

From API alignment to real framework contract tests, every step has a release.

v1.3.0

Yii 2 and Yii 3 land

Add Yii 2 and Yii 3 adapters and docs in 12 languages.

v1.2.5

Real framework contract tests

Add real Laravel contract tests and split two conflicting CI jobs.

v1.2.4

Install end-to-end coverage

Add end-to-end Install contract tests to close the last stub gap.

v1.2.0

Two critical fixes

Fix Webman and Hyperf config bugs; add a vinkla-aligned API.

Changelog

Recent releases; the full list is on GitHub Releases.

Latest v1.3.0 All versions
v1.3.02026-09-29

Add Yii 2 and Yii 3 adapters and sync docs to 12 languages.

v1.2.52026-09-25

Real Laravel contract tests and split conflicting CI jobs.

v1.2.42026-09-25

Add end-to-end Install contract tests and close the stub gap.

v1.2.32026-09-25

Fix the Hyperf contract job missing the coroutine extension.

v1.2.22026-09-25

Add framework contract tests and fix the Webman plugin switch.

v1.2.12026-09-25

Complete runtime and security notes and fix composer suggest.

Install and use

Install first, then run a minimal example.

PHP >= 8.0Full README
Install
composer require erikwang2013/hashids
Minimal example
use Erikwang2013\Hashids\HashidsFactory;
use Erikwang2013\Hashids\HashidsManager;

$manager = new HashidsManager(
    require __DIR__ . '/config/hashids.php',
    new HashidsFactory()
);

$hash = $manager->encode(1, 2, 3);
$ids = $manager->decode($hash);

Twelve Hashy expressions

Hover and it changes mood.

Search this site

Try “upload”, “migration” or “JWT”.