All Projects → vinkla → Laravel Hashids

vinkla / Laravel Hashids

Licence: mit
A Hashids bridge for Laravel

Programming Languages

PHP
23972 projects - #3 most used programming language

Projects that are alternatives of or similar to Laravel Hashids

Laravel Sitemap
Laravelium Sitemap generator for Laravel.
Stars: ✭ 1,231 (-28.18%)
Mutual labels:  laravel, composer
Laravel Backup
A easy-to-use backup manager for Laravel
Stars: ✭ 93 (-94.57%)
Mutual labels:  laravel, composer
Project
⭐️ Antares Project Application Skeleton. This is the very first place you should start. It allows you to create a brand new awesome project in easy few steps.
Stars: ✭ 84 (-95.1%)
Mutual labels:  laravel, composer
Optimus
🤖 Id obfuscation based on Knuth's multiplicative hashing method for PHP.
Stars: ✭ 1,084 (-36.76%)
Mutual labels:  hashids, laravel
Sms
Laravel SMS Gateway Integration Package
Stars: ✭ 112 (-93.47%)
Mutual labels:  laravel, composer
Laravel Restify
The fastest way to make a powerful JSON:API compatible Rest API with Laravel.
Stars: ✭ 62 (-96.38%)
Mutual labels:  laravel, composer
Laravel Bandwagon
Social proof package for Laravel
Stars: ✭ 93 (-94.57%)
Mutual labels:  laravel, composer
Htmlcache
Laravel middleware to cache the rendered html
Stars: ✭ 35 (-97.96%)
Mutual labels:  laravel, composer
Laravel Alert
A Bootstrap alert helper for Laravel
Stars: ✭ 110 (-93.58%)
Mutual labels:  laravel, composer
Laravel Stats
📈 Get insights about your Laravel or Lumen Project
Stars: ✭ 1,386 (-19.14%)
Mutual labels:  laravel, composer
Larrock Core
Core components for LarrockCMS
Stars: ✭ 46 (-97.32%)
Mutual labels:  laravel, composer
Rpg
Online Role Playing Game (based on Laravel)
Stars: ✭ 121 (-92.94%)
Mutual labels:  laravel, composer
Datagrid
Datagrid for Laravel v5
Stars: ✭ 44 (-97.43%)
Mutual labels:  laravel, composer
Easy Short Url
ESU 短网址,可在 Laravel、Yii、ThinkPHP 等框架 Composer 包引入,也可以独立搭建短网址站点
Stars: ✭ 71 (-95.86%)
Mutual labels:  laravel, composer
Lara Eye
Filter your Query\Builder using a structured query language
Stars: ✭ 39 (-97.72%)
Mutual labels:  laravel, composer
Docker Laravel
Laravel 5 with Dockerized Gulp, PHP-FPM, MySQL and nginx using docker-compose
Stars: ✭ 85 (-95.04%)
Mutual labels:  laravel, composer
Easyhttp
A Laravel HTTP-client to make HTTP request easier and log requests and responses
Stars: ✭ 20 (-98.83%)
Mutual labels:  laravel, composer
Nem Php
NEM Blockchain NIS API Wrapper and Software Development Kit for PHP
Stars: ✭ 32 (-98.13%)
Mutual labels:  laravel, composer
Thumbnail
Thumbnail for a given video using FFMpeg
Stars: ✭ 96 (-94.4%)
Mutual labels:  laravel, composer
Laravel Optimus
Transform your internal id's to obfuscated integers based on Knuth's integer hash. Laravel wrapper for the Optimus Library by Jens Segers with multiple connections support.
Stars: ✭ 119 (-93.06%)
Mutual labels:  hashids, laravel

hashids

Laravel Hashids

A Hashids bridge for Laravel.

// Encode integers.
Hashids::encode(4815162342);

// Decode strings.
Hashids::decode('1LLb3b4ck');

// Dependency injection example.
$hashidsManager->encode(911);

Build Status Monthly Downloads Latest Version

Installation

Require this package, with Composer, in the root directory of your project.

composer require vinkla/hashids

Configuration

Laravel Hashids requires connection configuration. To get started, you'll need to publish all vendor assets:

$ php artisan vendor:publish

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.

Default Connection Name

This option default is where you may specify which of the connections below you wish to use as your default connection for all work. Of course, you may use many connections at once using the manager class. The default value for this setting is main.

Hashids Connections

This option connections is where each of the connections are setup for your application. Example configuration has been included, but you may add as many connections as you would like.

Usage

Here you can see an example of you may use this package. Out of the box, the default adapter is main. After you enter your authentication details in the config file, it will just work:

// You can alias this in config/app.php.
use Vinkla\Hashids\Facades\Hashids;

// We're done here - how easy was that, it just works!
Hashids::encode(4815162342);

// This example is simple and there are far more methods available.
Hashids::decode('doyouthinkthatsairyourebreathingnow');

The manager will behave like it is a Hashids\Hashids class. If you want to call specific connections, you can do that with the connection method:

use Vinkla\Hashids\Facades\Hashids;

// Writing this...
Hashids::connection('main')->encode($id);

// ...is identical to writing this
Hashids::encode($id);

// and is also identical to writing this.
Hashids::connection()->encode($id);

// This is because the main connection is configured to be the default.
Hashids::getDefaultConnection(); // This will return main.

// We can change the default connection.
Hashids::setDefaultConnection('alternative'); // The default is now alternative.

If you prefer to use dependency injection over facades, then you can inject the manager:

use Vinkla\Hashids\HashidsManager;

class Foo
{
    protected $hashids;

    public function __construct(HashidsManager $hashids)
    {
        $this->hashids = $hashids;
    }

    public function bar($id)
    {
        $this->hashids->encode($id)
    }
}

App::make('Foo')->bar();

For more information on how to use the Hashids\Hashids class, check out the docs at hashids/hashids.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].