{"id":15489466,"url":"https://github.com/roukmoute/hashids-bundle","last_synced_at":"2026-01-18T16:00:46.378Z","repository":{"id":45540246,"uuid":"61156707","full_name":"roukmoute/hashids-bundle","owner":"roukmoute","description":"Integrates hashids/hashids in a Symfony project","archived":false,"fork":false,"pushed_at":"2026-01-18T10:04:13.000Z","size":74,"stargazers_count":45,"open_issues_count":4,"forks_count":16,"subscribers_count":2,"default_branch":"master","last_synced_at":"2026-01-18T13:51:26.060Z","etag":null,"topics":["hashids","php","symfony-bundle"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/roukmoute.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG-2.0.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2016-06-14T21:24:48.000Z","updated_at":"2024-02-29T22:54:55.000Z","dependencies_parsed_at":"2024-10-30T03:27:41.382Z","dependency_job_id":"60f9684e-4eb1-46b0-8d29-d9fdfd77c850","html_url":"https://github.com/roukmoute/hashids-bundle","commit_stats":{"total_commits":49,"total_committers":13,"mean_commits":3.769230769230769,"dds":0.7142857142857143,"last_synced_commit":"10bb7d91c1ff6a695a6a1685fcb34f0d0acf0528"},"previous_names":[],"tags_count":25,"template":false,"template_full_name":null,"purl":"pkg:github/roukmoute/hashids-bundle","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/roukmoute%2Fhashids-bundle","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/roukmoute%2Fhashids-bundle/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/roukmoute%2Fhashids-bundle/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/roukmoute%2Fhashids-bundle/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/roukmoute","download_url":"https://codeload.github.com/roukmoute/hashids-bundle/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/roukmoute%2Fhashids-bundle/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28541065,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-18T14:59:57.589Z","status":"ssl_error","status_checked_at":"2026-01-18T14:59:46.540Z","response_time":98,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["hashids","php","symfony-bundle"],"created_at":"2024-10-02T07:06:00.238Z","updated_at":"2026-01-18T16:00:46.366Z","avatar_url":"https://github.com/roukmoute.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![SymfonyInsight](https://insight.symfony.com/projects/be961d5c-da56-44b1-a094-e27066802a2d/mini.svg)](https://insight.symfony.com/projects/be961d5c-da56-44b1-a094-e27066802a2d)\n[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/roukmoute/hashids-bundle/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/roukmoute/hashids-bundle/?branch=master)\n![Packagist Downloads](https://img.shields.io/packagist/dt/roukmoute/hashids-bundle)\n\n# HashidsBundle\n\n\u003e **Note:** This bundle is maintained, but for **new projects**, consider using [roukmoute/sqids-bundle](https://github.com/roukmoute/sqids-bundle) instead.\n\u003e [Sqids](https://sqids.org/) is the official successor to Hashids, featuring a simpler algorithm, consistent cross-language output, and a built-in profanity blocklist.\n\u003e However, Sqids is **not a drop-in replacement** — it produces different IDs. Only migrate if you don't rely on previously generated Hashids.\n\u003e See the [official Hashids recommendation](https://github.com/hashids/.github/blob/main/profile/README.md) for more details.\n\nIntegrates [hashids/hashids](https://github.com/ivanakimov/hashids.php) in a Symfony project.\n\n## Installation using composer\n\nThese commands requires you to have Composer installed globally.  \nOpen a command console, enter your project directory and execute the following \ncommands to download the latest stable version of this bundle:\n\n### Using Symfony Flex\n\n```\n    composer config extra.symfony.allow-contrib true\n    composer req roukmoute/hashids-bundle\n```\n\n### Using Symfony Framework only\n\n```\n    composer require roukmoute/hashids-bundle\n```\n\nIf this has not been done automatically, enable the bundle by adding the \nfollowing line in the `config/bundles.php` file of your project:\n\n```php\n\u003c?php\n\nreturn [\n    …,\n    Roukmoute\\HashidsBundle\\RoukmouteHashidsBundle::class =\u003e ['all' =\u003e true],\n];\n```\n\n## Configuration\n\nThe configuration (`config/packages/roukmoute_hashids.yaml`) looks as follows :\n\n```yaml\nroukmoute_hashids:\n\n    # if set, the hashids will differ from everyone else's\n    salt:            \"\"\n\n    # if set, will generate minimum length for the id\n    # 0 — meaning hashes will be the shortest possible length\n    min_hash_length: 0\n\n    # if set, will use only characters of alphabet string\n    alphabet:        \"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890\"\n\n    # if set to true, it will continue with the next available value resolvers\n    passthrough:     false\n\n    # if set to true, it tries to convert all arguments passed to the controller\n    auto_convert:    false\n```\n\n## Usage\n\n```php\n\nuse Hashids\\HashidsInterface;\n\npublic function postShow(HashidsInterface $hashids): Response\n{\n    $hashids-\u003e…\n}\n```\n\nNext it's the same things of [official documentation](https://hashids.org/php/).\n\n## Hashids Value Resolver\n\nThe hashids value resolver attempts to convert any attribute set in the route into\nan integer parameter.\n\n### Using the `#[Hashid]` attribute\n\nThe recommended way is to use the `#[Hashid]` attribute on your controller parameter:\n\n```php\nuse Roukmoute\\HashidsBundle\\Attribute\\Hashid;\nuse Symfony\\Component\\Routing\\Attribute\\Route;\n\n#[Route('/posts/{id}')]\npublic function show(#[Hashid] int $id): Response\n{\n    // $id is automatically decoded from the hashid\n}\n```\n\nYou can also specify a different route parameter name using the `parameter` option:\n\n```php\n#[Route('/posts/{hash}')]\npublic function show(#[Hashid(parameter: 'hash')] int $id): Response\n{\n    // The 'hash' route parameter is decoded into $id\n}\n```\n\n### Using route aliases\n\nYou can also use `hashid` or `id` as route parameter names:\n\n```php\n#[Route('/users/{hashid}')]\npublic function getAction(int $user): Response\n{\n}\n```\n\nor\n\n```php\n#[Route('/users/{id}')]\npublic function getAction(int $user): Response\n{\n}\n```\n\n### Using the `_hash_` prefix\n\nYou can have several hashids in the same URL using the `_hash_` prefix:\n\n```php\n#[Route('/users/{_hash_user}/status/{_hash_status}')]\npublic function getAction(int $user, int $status): Response\n{\n}\n```\n\nThe keys must match the controller parameter names:\n\n```php\n//                          _hash_user  _hash_status\n//                                 ↕            ↕\npublic function getAction(int $user, int $status)\n```\n\nYou will receive a `LogicException` if an explicit hash could not be decoded correctly.\n\n## Using auto_convert\n\n`auto_convert` tries to convert all arguments in controller.\n\n```yaml\nroukmoute_hashids:\n  auto_convert: true\n```\n\nBased on the example above:\n\n```php\n#[Route('/users/{user}/status/{status}')]\npublic function getAction(int $user, int $status): Response\n{\n}\n```\n\nIt will not be possible to get an exception of type `LogicException` from the\nbundle if it is activated.\n\n## Using passthrough\n\n`passthrough` allows to continue with the next available value resolvers.\nSo if you would like to retrieve an object instead of an integer, just activate\npassthrough:\n\n```yaml\nroukmoute_hashids:\n    passthrough: true\n```\n\nBased on the example above:\n\n```php\n#[Route('/users/{hashid}')]\npublic function getAction(User $user): Response\n{\n}\n```\n\nAs you can see, the passthrough feature allows to use `EntityValueResolver`\nor any other `ValueResolverInterface` you would have created.\n\n## Twig Extension\n### Usage\n\n```twig\n{{ path('users.show', {'hashid': user.id | hashids_encode }) }}\n{{ app.request.query.get('hashid') | hashids_decode }}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Froukmoute%2Fhashids-bundle","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Froukmoute%2Fhashids-bundle","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Froukmoute%2Fhashids-bundle/lists"}