PHPackages                             uniacid/hashid-bundle - 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. [Security](/categories/security)
4. /
5. uniacid/hashid-bundle

ActiveSymfony-bundle[Security](/categories/security)

uniacid/hashid-bundle
=====================

Modernized Symfony bundle for automatic encoding/decoding of route parameters using Hashids - PHP 8.3 &amp; Symfony 6.4/7.0 ready fork of pgs-soft/hashid-bundle

v4.0.1(8mo ago)027MITPHPPHP ^8.1CI failing

Since Feb 11Pushed 8mo agoCompare

[ Source](https://github.com/uniacid/HashId)[ Packagist](https://packagist.org/packages/uniacid/hashid-bundle)[ Docs](https://github.com/uniacid/HashId)[ RSS](/packages/uniacid-hashid-bundle/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (2)Dependencies (14)Versions (24)Used By (0)

HashId Bundle - Modernized Fork
===============================

[](#hashid-bundle---modernized-fork)

> **A modernized fork of [PGSSoft/HashId](https://github.com/PGSSoft/HashId) bundle, updated for PHP 8.3 and Symfony 6.4/7.0**

[![PHP 8.1+](https://camo.githubusercontent.com/7535257ca228724c93658bd52583d4e47a9bab02c356abf6e54c1d575f2151e6/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e312532422d626c75652e737667)](https://camo.githubusercontent.com/7535257ca228724c93658bd52583d4e47a9bab02c356abf6e54c1d575f2151e6/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e312532422d626c75652e737667)[![Symfony 6.4/7.0](https://camo.githubusercontent.com/ef18f9e79bed6357308c536aa32408af0d74c7c6ce7e0cbdef8b9f6e5ee0c358/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f53796d666f6e792d362e34253230253743253230372e302d677265656e2e737667)](https://camo.githubusercontent.com/ef18f9e79bed6357308c536aa32408af0d74c7c6ce7e0cbdef8b9f6e5ee0c358/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f53796d666f6e792d362e34253230253743253230372e302d677265656e2e737667)[![Latest Stable Version](https://camo.githubusercontent.com/dca67acc02c4ddcbf68ea11cff3468e5439e7f3d0f7dd03137a8e6728bb363d8/68747470733a2f2f706f7365722e707567782e6f72672f756e69616369642f6861736869642d62756e646c652f762f737461626c65)](https://packagist.org/packages/uniacid/hashid-bundle)[![License](https://camo.githubusercontent.com/1b089d471d7a6302e77f7a488c2421ab52adce68139ab370c61d12f4de9ab328/68747470733a2f2f706f7365722e707567782e6f72672f756e69616369642f6861736869642d62756e646c652f6c6963656e7365)](https://packagist.org/packages/uniacid/hashid-bundle)

Symfony bundle for automatically encoding integer route parameters and decoding request parameters using [Hashids](http://www.hashids.org/)

🚀 Version 4.0 Features
----------------------

[](#-version-40-features)

- **PHP 8.1+ Attributes**: Native `#[Hash]` attributes replace annotations
- **Modern PHP Support**: PHP 8.1, 8.2, and 8.3 features including readonly properties, typed constants
- **Symfony 6.4 LTS &amp; 7.0**: Full compatibility with latest Symfony versions
- **75.3% Rector Automation**: Automated migration from v3.x using Rector
- **PHPStan Level 9**: Enhanced type safety and code quality
- **Multiple Hasher Support**: Configure different hashers with unique settings

Why Use HashId?
---------------

[](#why-use-hashid)

Transform predictable integer URL parameters into obfuscated strings automatically:

- `/order/315` → `/order/4w9aA11avM`
- `/user/1337` → `/user/X46dBNxd79`
- `/hash-id/demo/decode/216/30` → `/hash-id/demo/decode/X46dBNxd79/ePOwvANg`

### Benefits

[](#benefits)

- **Security**: Prevent resource enumeration attacks
- **Transparency**: No code changes needed - works with existing `generateUrl()` and `{{ url() }}`
- **Compatibility**: Full Doctrine ParamConverter support
- **Flexibility**: Configure salt, minimum length, and alphabet

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

[](#installation)

```
composer require uniacid/hashid-bundle:^4.0
```

### Requirements

[](#requirements)

- PHP 8.1 or higher (8.3 recommended)
- Symfony 6.4 LTS or 7.0
- hashids/hashids ^4.0 or ^5.0

Configuration
-------------

[](#configuration)

```
# config/packages/pgs_hash_id.yaml
pgs_hash_id:
    salt: '%env(HASHID_SALT)%'
    min_hash_length: 10
    alphabet: 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890'

    # v4.0 Compatibility Settings (optional)
    compatibility:
        suppress_deprecations: false  # Set to true during migration
        prefer_attributes: true        # Use attributes when both are present
```

Usage
-----

[](#usage)

### Modern Usage with PHP 8.1+ Attributes (Recommended)

[](#modern-usage-with-php-81-attributes-recommended)

```
