PHP code example of pivar / hashids

1. Go to this page and download the library: Download pivar/hashids library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

pivar / hashids example snippets


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

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

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

Vinkla\Hashids\HashidsServiceProvider::class

'Hashids' => Vinkla\Hashids\Facades\Hashids::class

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

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

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

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.

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();
bash
$ php artisan vendor:publish