junityco / laravel-hashids
A Hashids service provider for Laravel
Installs: 4 065
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 3
Forks: 1
Open Issues: 0
Requires
- php: ^5.6.4 || ^7.0
- hashids/hashids: ^2.0
- illuminate/contracts: 5.3.* || 5.4.*
- illuminate/support: 5.3.* || 5.4.*
This package is not auto-updated.
Last update: 2023-07-06 16:22:55 UTC
README
Hashids is small PHP library to generate YouTube-like ids from numbers. Use it when you don't want to expose your database ids to the user: http://hashids.org/php
Installation
Require this package, with Composer, in the root directory of your project.
$ composer require junityco/laravel-hashids
Add the service provider to config/app.php
in the providers
array.
Junity\Hashids\HashidsServiceProvider::class
If you want you can use the facade. Add the reference in config/app.php
to your aliases array.
'Hashids' => Junity\Hashids\Facades\Hashids::class
Configuration
Laravel Hashids requires connection configuration. To get started, you'll need to publish all vendor assets:
$ php artisan vendor:publish --provider="Junity\Hashids\HashidsServiceProvider"
This will create a config/hashids.php
file in your app that you can modify to set your configuration. Also, make sure you check for changes to the original config file in this package between releases.
Quick Example
use Junity\Hashids\Facades\Hashids; $id = Hashids::encode(1, 2, 3); // o2fXhV $numbers = Hashids::decode($id); // [1, 2, 3]
There are other methods in this package that are not documented here. For documentation visit the Hashids package homepage.