Download the PHP package danphyxius/hashids without Composer
On this page you can find all versions of the php package danphyxius/hashids. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download danphyxius/hashids
More information about danphyxius/hashids
Files in danphyxius/hashids
Informations about the package hashids
Hashids for Laravel 4
This package uses the classes created by hashids.org
Generate hashes from numbers, like YouTube or Bitly. Use hashids when you do not want to expose your database ids to the user.
Installation
Begin by installing the package through Composer. Edit your project's composer.json
file to require ludo237/hashids
.
Next use Composer to update your project from the the Terminal:
Once the package has been installed you'll need to add the service provider. Open your app/config/app.php
configuration file, and add a new item to the providers
array.
After doing this you also need to add an alias. In your app/config/app.php
file, add this to the aliases
array.
Now last but not least you need to publish to package configuration from your Terminal:
Usage
Once you've followed all the steps and completed the installation you can use Hashids.
Encrypting
You can simply encrypt on id:
or multiple..
Decrypting
It's the same thing but the other way around:
or multiple..
Injecting Hashids
Now it's also possible to have Hashids injected into your class. Lets look at this controller as an example..
The original classname and namespace has been bound in the IoC container to return our instantiated Hashids class.
Using IoC
Create a Hashids instance with the IoC
That's it!
For documentation about Hashids itself, go to: https://github.com/ivanakimov/hashids.php.
Hopefully you'll enjoy this package and thanks to Ivan Akimov (@ivanakimov) for making Hashids. All credits for the Hashids package go to him.