junityco/laravel-hashids

This package is abandoned and no longer maintained. No replacement package was suggested.

A Hashids service provider for Laravel

1.5 2017-02-17 15:18 UTC

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

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.