junityco / laravel-hashids by Junity

A Hashids service provider for Laravel
3,896
1
3
Package Data
Maintainer Username: Junity
Maintainer Contact: info@junity.co (Vladimir Gaidushin)
Package Create Date: 2017-02-17
Package Last Update: 2017-02-17
Home Page:
Language: PHP
License: MIT
Last Refreshed: 2023-03-29 03:23:00
Package Statistics
Total Downloads: 3,896
Monthly Downloads: 0
Daily Downloads: 0
Total Stars: 1
Total Watchers: 3
Total Forks: 1
Total Open Issues: 0

Hashids for Laravel

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

Total Downloads Latest Version License

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.