2017 © Pedro Peláez
 

library l4-hashids

A Laravel 4 package for the official hashids library

image

mrynk/l4-hashids

A Laravel 4 package for the official hashids library

  • Tuesday, March 4, 2014
  • by mrynk
  • Repository
  • 1 Watchers
  • 3 Stars
  • 347 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 5 Versions
  • 0 % Grown

The README.md

l4-hashids

A Laravel 4 package for the official hashids library, (*1)

Installation

Add mrynk\l4-hashids as a requirement to composer.json:, (*2)

{
    "require": {
        "mrynk/l4-hashids": "master"
    }
}

Update your packages with composer update or install with composer install., (*3)

Once Composer has installed or updated your packages you need to register Hashids with Laravel itself. Open up app/config/app.php and find the providers key towards the bottom and add:, (*4)

'Mrynk\L4Hashids\L4HashidsServiceProvider'

Configuration

L4-Hashids's configuration file can be extended by creating app/config/packages/mrynk/l4-hashids/config.php. You can find the default configuration file at vendor/mrynk/l4-hashids/src/config/config.php., (*5)

You can quickly publish a configuration file by running the following Artisan command., (*6)

$ php artisan config:publish mrynk/l4-hashids

Usage

You can use Hashids to obfuscate your url id's., (*7)

Use it in your controller like:, (*8)

public function myAction( $pHash )
{
    $id = Hashids::decrypt( $pHash );
    Model::find( reset( $id ) );
}

Since v2.0 you can define different setting groups. Obviously default is the default group. To use another you can explicitly tell so:, (*9)

Use it in your controller like:, (*10)

public function myAction( $pHash )
{
    $id = Hashids::make('groupname')->decrypt( $pHash );
    Model::find( reset( $id ) );
}

A more cleaner way would be to use it in your route model binding, (*11)

Route::bind('user', function( $value, $route )
{
    if( $result = User::find( Hashids::decrypt( $value ) ) )
        return $result;
    throw new NotFoundException;

});

The Versions

04/03 2014

dev-master

9999999-dev

A Laravel 4 package for the official hashids library

  Sources   Download

MIT

The Requires

 

by Michel Ypma

laravel hashids mrynk

04/03 2014

v2.1

2.1.0.0

A Laravel 4 package for the official hashids library

  Sources   Download

MIT

The Requires

 

by Michel Ypma

laravel hashids mrynk

07/02 2014

v2.0

2.0.0.0

A Laravel 4 package for the official hashids library

  Sources   Download

MIT

The Requires

 

by Michel Ypma

laravel hashids mrynk

25/09 2013

v1.1

1.1.0.0

A Laravel 4 package for the official hashids library

  Sources   Download

MIT

The Requires

 

by Michel Ypma

laravel hashids mrynk

09/09 2013

v1.0

1.0.0.0

A Laravel 4 package for the official hashids library

  Sources   Download

MIT

The Requires

 

by Michel Ypma

laravel hashids mrynk