PHPackages                             lokhman/silex-hashids - 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. lokhman/silex-hashids

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

lokhman/silex-hashids
=====================

Silex 2.0+ service provider for Hashids library

2.0.1(9y ago)0332MITPHP

Since Jan 24Pushed 9y ago1 watchersCompare

[ Source](https://github.com/lokhman/silex-hashids)[ Packagist](https://packagist.org/packages/lokhman/silex-hashids)[ RSS](/packages/lokhman-silex-hashids/feed)WikiDiscussions master Synced 4d ago

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

silex-hashids
=============

[](#silex-hashids)

[![StyleCI](https://camo.githubusercontent.com/dab0bbd5b4a3924cc95028a2cc088183e8e293986e382e0f16b499e77ef89612/68747470733a2f2f7374796c6563692e696f2f7265706f732f37393930373734332f736869656c643f6272616e63683d6d6173746572)](https://styleci.io/repos/79907743)

[Hashids](http://hashids.org/php/) Service provider for [**Silex 2.0+**](http://silex.sensiolabs.org/) micro-framework.

> This project is a part of [`silex-tools`](https://github.com/lokhman/silex-tools) library.

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

[](#installation)

You can install `silex-hashids` with [Composer](http://getcomposer.org):

```
composer require lokhman/silex-hashids

```

Documentation
------------------------------------------------------

[](#documentation)

Enable `HashidsServiceProvider` from `Provider` namespace to support brilliant [Hashids library](http://hashids.org/php/). You may setup either a single or multiple profiles to use in your application.

```
use Lokhman\Silex\Provider\HashidsServiceProvider;

$app->register(new HashidsServiceProvider(), [
    // default options for all profiles
    'hashids.options' => [
        'salt' => '',
        'min_length' => 0,
        'alphabet' => 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890',
    ],
    // optionally set multiple profiles
    'hashids.profiles' => [
        'profile1' => [
            'min_length' => 8,
        ],
        'profile2' => [
            'salt' => 'this is my salt',
            'alphabet' => 'abcdefghijklmnopqrstuvwxyz',
        ],
    ],
]);

// single profile encoding
$hash = $app['hashids']->encode(1, 2, 3);
$app['hashids']->encode(1, 2, 3) === $hash;
$app->hashids([1, 2, 3]) === $hash;

// single profile decoding
$id = $app['hashids']->decode($hash);
$app['hashids']->decode($hash) === $id;
$app->hashids($hash) === $id;

// multiple profiles encoding
$hash = $app['hashids']['profile1']->encode(1, 2, 3);
$app['hashids:profile1']->encode(1, 2, 3) === $hash;
$app->hashids([1, 2, 3], 'profile1') === $hash;

// multiple profiles decoding
$id = $app['hashids']['profile1']->decode($hash);
$app['hashids:profile1']->decode($hash) === $id;
$app->hashids($hash, 'profile1') === $id;

```

**N.B.:** To use `hashids()` application method, include `HashidsTrait` to your `Application` class. This method returns `FALSE` on error, and if given hash contains a single encoded `id`, integer is returned, otherwise array.

Additionally, the service provider adds support for auto-conversion of hashed parameters in routes if you specify them with `__hashids_` prefix.

```
// GET /users/jR (single profile)
$app->get('/users/{__hashids_id}', function(Application $app, $id) {
    return $app->json(['id' => $id]);  // { "id": 1 }
});

// GET /users/olejRejN (multiple profiles)
$app->get('/users/{__hashids_profile1_id}', function(Application $app, $id) {
    return $app->json(['id' => $id]);  // { "id": 1 }
});

```

License
------------------------------------------

[](#license)

Library is available under the MIT license. The included LICENSE file describes this in detail.

###  Health Score

29

—

LowBetter than 57% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity64

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 ~40 days

Total

2

Last Release

3407d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/17a4b2bb3c64905c2663115cb0a3ef36854123b51709645576a591fb72fbef10?d=identicon)[lokhman](/maintainers/lokhman)

---

Top Contributors

[![lokhman](https://avatars.githubusercontent.com/u/7714105?v=4)](https://github.com/lokhman "lokhman (5 commits)")

---

Tags

hashidssilextoolshashidstoolssilex

### Embed Badge

![Health badge](/badges/lokhman-silex-hashids/health.svg)

```
[![Health](https://phpackages.com/badges/lokhman-silex-hashids/health.svg)](https://phpackages.com/packages/lokhman-silex-hashids)
```

###  Alternatives

[vinkla/hashids

A Hashids bridge for Laravel

2.1k14.2M78](/packages/vinkla-hashids)[deligoez/laravel-model-hashid

Generate, Save, and Route Stripe/Youtube-like Hash IDs for Laravel Eloquent Models

166114.2k](/packages/deligoez-laravel-model-hashid)[solspace/craft-freeform

The most flexible and user-friendly form building plugin!

54681.3k19](/packages/solspace-craft-freeform)[igorw/config-service-provider

A config ServiceProvider for Silex with support for php, json and yaml.

215639.8k13](/packages/igorw-config-service-provider)[balping/laravel-hashslug

Package providing a trait to use Hashids on a model

25191.7k2](/packages/balping-laravel-hashslug)[jbinfo/mobile-detect-service-provider

A mobile detect ServiceProvider for Silex, based on Mobile-Detect library.

25333.2k](/packages/jbinfo-mobile-detect-service-provider)

PHPackages © 2026

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