Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/pgssoft/hashid
Replace your integer url params in Symfony applications and hide under unpredictable strings.
https://github.com/pgssoft/hashid
hashid obfuscator param-converter pgs php routing symfony symfony-bundle
Last synced: about 1 month ago
JSON representation
Replace your integer url params in Symfony applications and hide under unpredictable strings.
- Host: GitHub
- URL: https://github.com/pgssoft/hashid
- Owner: PGSSoft
- License: mit
- Created: 2018-03-15T09:02:41.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2023-10-17T21:11:12.000Z (about 1 year ago)
- Last Synced: 2024-07-09T09:56:13.855Z (6 months ago)
- Topics: hashid, obfuscator, param-converter, pgs, php, routing, symfony, symfony-bundle
- Language: PHP
- Homepage:
- Size: 2.11 MB
- Stars: 12
- Watchers: 4
- Forks: 3
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# [![PGS Software](https://www.pgs-soft.com/pgssoft-logo.png)](https://www.pgs-soft.com) / HashId
![PHP from Packagist](https://img.shields.io/packagist/php-v/symfony/symfony.svg)
[![Build Status](https://travis-ci.org/PGSSoft/HashId.svg?branch=3.0)](https://travis-ci.org/PGSSoft/HashId)
[![Code Coverage](https://scrutinizer-ci.com/g/PGSSoft/HashId/badges/coverage.png?b=dev-master)](https://scrutinizer-ci.com/g/PGSSoft/HashId/?branch=dev-master)
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/PGSSoft/HashId/badges/quality-score.png?b=dev-master)](https://scrutinizer-ci.com/g/PGSSoft/HashId/?branch=dev-master)Symfony bundle for encoding integer route parameters and decoding request parameters with
***
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](http://symfony.com/doc/current/bundles/SensioFrameworkExtraBundle/annotations/converters.html#doctrine-converter) compatible## Instalation
```bash
composer require pgs-soft/hashid-bundle
```## Hashids configuration
```yaml
# config/packages/pgs_hash_id.yamlpgs_hash_id:
converter:
hashids:
salt: 'my super salt'
min_hash_length: 20
alphabet: 'qwertyasdzxc098765-'
```## Controller configuration
```php
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](src/Controller/DemoController.php).
## Contributing
Bug reports and pull requests are welcome on GitHub at [https://github.com/PGSSoft/HashId](https://github.com/PGSSoft/HashId).
## About
The project maintained by [software development agency](https://www.pgs-soft.com/) [PGS Software](https://www.pgs-soft.com/).
See our other [open-source projects](https://github.com/PGSSoft) or [contact us](https://www.pgs-soft.com/contact-us/) to develop your product.## Follow us
[![Twitter URL](https://img.shields.io/twitter/url/http/shields.io.svg?style=social)](https://twitter.com/intent/tweet?text=https://github.com/PGSSoft/InAppPurchaseButton)
[![Twitter Follow](https://img.shields.io/twitter/follow/pgssoftware.svg?style=social&label=Follow)](https://twitter.com/pgssoftware)