PHPackages                             icanhazstring/expressive-hashids-middleware - 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. icanhazstring/expressive-hashids-middleware

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

icanhazstring/expressive-hashids-middleware
===========================================

PSR-15/PSR-7 compliant middleware using ivanakimov/hashids.php

v1.0(7y ago)29MITPHPPHP ^7.1.3

Since May 23Pushed 7y ago1 watchersCompare

[ Source](https://github.com/icanhazstring/expressive-hashids-middleware)[ Packagist](https://packagist.org/packages/icanhazstring/expressive-hashids-middleware)[ RSS](/packages/icanhazstring-expressive-hashids-middleware/feed)WikiDiscussions master Synced 2mo ago

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

icanhazstring/expressive-hashids-middleware
===========================================

[](#icanhazstringexpressive-hashids-middleware)

PSR-15/PSR-7 compliant middleware using ivanakimov/hashids.php

[![Build Status](https://camo.githubusercontent.com/f6eb58e35899f10d854a890712a3b8a584377db40b2744be683e4128828b74db/68747470733a2f2f6170692e7472617669732d63692e6f72672f6963616e68617a737472696e672f657870726573736976652d686173686964732d6d6964646c65776172652e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/icanhazstring/expressive-hashids-middleware) [![Code Climate](https://camo.githubusercontent.com/36db92dd7c4d7223a9ed737abf97d7609fbf44ef38fa95b7375d283250fedc70/68747470733a2f2f636f6465636c696d6174652e636f6d2f6769746875622f6963616e68617a737472696e672f657870726573736976652d686173686964732d6d6964646c65776172652f6261646765732f6770612e737667)](https://codeclimate.com/github/icanhazstring/expressive-hashids-middleware) [![Test Coverage](https://camo.githubusercontent.com/bf284e556150546bafad831192ef0db751cc524cd224acdfe1b348b5dd4f8cac/68747470733a2f2f636f6465636c696d6174652e636f6d2f6769746875622f6963616e68617a737472696e672f657870726573736976652d686173686964732d6d6964646c65776172652f6261646765732f636f7665726167652e737667)](https://codeclimate.com/github/icanhazstring/expressive-hashids-middleware/coverage)

Install
-------

[](#install)

You can install the *expressive-hashids-middleware* library with composer:

```
$ composer require icanhazstring/expressive-hashids-middleware
```

Workflow
--------

[](#workflow)

The main purpose of the middleware is to obfuscate internal IDs from the outside world. That said, you don't have to change your internal id handling (like autoincrement in your db) to use this middleware.

Any incoming request in the form of `/api/resource/{id}` will be decoded using this middleware. So for example (default configuration):

`/api/user/ABC` (where `ABC` is the encoded value) will produce request attributes like this:

```
$attributes = $request->getAttributes();

/*
[
    'id' => 'ABC',
    '__hashids_identifier' => 1
]
*/
```

> The middleware **won't override** attributes! You can use the `HashidsMiddleware::ATTRIBUTE` constant to easy access this attribute.

Usage
-----

[](#usage)

### Using expressive

[](#using-expressive)

Include the `HashidsConfigProvider` inside your `config/config.php`:

```
$aggregator = new ConfigAggregator([
    ...
    \icanhazstring\Hashids\HashidsConfigProvider::class,
    ...
]);
```

Make sure the `HashidsConfigProvider` is included before your autoload files!

### Custom configuration

[](#custom-configuration)

If you want to change parameters of `Hashids`, simply provide the `HashidsConfigProvider::CONFIG_KEY` inside your autoload configuration and change the values to your desire.

```
return [
    \icanhazstring\Hashids\HashidsConfigProvider::CONFIG_KEY => [
        'salt'                 => '',
        'minHashLength'        => 0,
        'alphabet'             => 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890',
        'resource_identifiert' => 'id'
    ]
];
```

### Using the strategy

[](#using-the-strategy)

If you want, you can use the hydration/extraction strategy provided to decode/encode data from and into your objects.

To use the strategy, simply use the provided delegator `HashidsHydratorDelegatorFactory` and append it as delegator for your hydrator.

```
class ConfigProvider
{
    public function __invoke(): array
    {
        return [
            'hydrators' => [
                'delegators' => [
                    ArraySerializable::class => [
                        \icanhazstring\Hashids\Hydrator\HashidsHydratorDelegatorFactory:class
                    ]
                ]
            ],
        ];
    }
}
```

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 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

Unknown

Total

1

Last Release

2909d ago

### Community

Maintainers

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

---

Top Contributors

[![icanhazstring](https://avatars.githubusercontent.com/u/883543?v=4)](https://github.com/icanhazstring "icanhazstring (6 commits)")

---

Tags

hashidsmiddlewarepsr-15psr-7

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/icanhazstring-expressive-hashids-middleware/health.svg)

```
[![Health](https://phpackages.com/badges/icanhazstring-expressive-hashids-middleware/health.svg)](https://phpackages.com/packages/icanhazstring-expressive-hashids-middleware)
```

###  Alternatives

[cakephp/cakephp

The CakePHP framework

8.8k18.5M1.6k](/packages/cakephp-cakephp)[jaxon-php/jaxon-core

Jaxon is an open source PHP library for easily creating Ajax web applications

73142.3k25](/packages/jaxon-php-jaxon-core)[neos/flow

Flow Application Framework

862.0M450](/packages/neos-flow)[mezzio/mezzio-authentication-oauth2

OAuth2 (server) authentication middleware for Mezzio and PSR-7 applications.

28483.0k2](/packages/mezzio-mezzio-authentication-oauth2)[rareloop/lumberjack-core

A powerful MVC framework for the modern WordPress developer. Write better, more expressive and easier to maintain code

42155.0k19](/packages/rareloop-lumberjack-core)[mezzio/mezzio-authentication

Authentication middleware for Mezzio and PSR-7 applications

121.6M26](/packages/mezzio-mezzio-authentication)

PHPackages © 2026

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