pgs-soft / hashid-bundle
Symfony Hash Id
Installs: 10 031
Dependents: 0
Suggesters: 0
Security: 0
Stars: 12
Watchers: 4
Forks: 3
Open Issues: 8
Type:symfony-bundle
Requires
- php: >=7.2.5
- doctrine/annotations: ^1.6
- hashids/hashids: >=2.0
- symfony/config: ~4.4|~5.0
- symfony/dependency-injection: ^4.1.12|^5.0
- symfony/routing: ^5.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^2.10
- phpstan/phpstan: ^0.12
- phpunit/phpunit: ^7.0
- sebastian/phpcpd: ^4.0
- sensio/framework-extra-bundle: ^5.1
- squizlabs/php_codesniffer: ^3.2
- symfony/browser-kit: ^4.0
- symfony/http-kernel: ^4.4.13|^5.1.5
- symfony/yaml: ^4.0
This package is auto-updated.
Last update: 2024-10-27 06:49:17 UTC
README
Symfony bundle for encoding integer route parameters and decoding request parameters with http://www.hashids.org/
Please use this version with Symfony ≥5.0
Replace predictable integer url parameters in easy way:
/hash-id/demo/decode/216/30
=>/hash-id/demo/decode/X46dBNxd79/30
/order/315
=>/order/4w9aA11avM
Pros:
- no need to use extra filters - use
{{ url('route_name', {'id': 1}) }}
in twig template or$this->generateUrl('route_name', ['id' => 1]);
in controller or service - Doctrine Converter compatible
Instalation
composer require pgs-soft/hashid-bundle
Hashids configuration
# config/packages/pgs_hash_id.yaml pgs_hash_id: converter: hashids: salt: 'my super salt' min_hash_length: 20 alphabet: 'qwertyasdzxc098765-'
Controller configuration
use Pgs\HashIdBundle\Annotation\Hash; class UserController extends Controller { /** * @Hash("id") */ public function edit(int $id) { //... } /** * Process multiple parameters - 'oneMore' will not be processed * @Route(name="test", path="/test/{id}/{other}/{oneMore}") * @Hash({"id","other"}) */ public function test(int $id, int $other, int $oneMore) { //... } }
You can also check our DemoController.
Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/PGSSoft/HashId.
About
The project maintained by software development agency PGS Software. See our other open-source projects or contact us to develop your product.