1. Go to this page and download the library: Download erikwang2013/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/ */
erikwang2013 / hashids example snippets
use Erikwang2013\Hashids\HashidsFactory;
use Erikwang2013\Hashids\HashidsManager;
$manager = new HashidsManager(
use Erikwang2013\Hashids\Laravel\Facades\Hashids;
$hash = Hashids::encode(1, 2, 3);
$numbers = Hashids::decode($hash);
use Erikwang2013\Hashids\Laravel\Facades\Hashids;
$hash = Hashids::connection('alternative')->encode(100);
use Erikwang2013\Hashids\HashidsManager;
public function __construct(private HashidsManager $hashids) {}
$this->hashids->encode(1);
$this->hashids->connection('alternative')->encode(2);
use Hashids\Hashids;
public function __construct(private Hashids $hashids) {}
return [
'enable' => false,
];
use support\Request;
use Erikwang2013\Hashids\HashidsManager;
use Hashids\Hashids;
class DemoController
{
public function index(Request $request, HashidsManager $manager)
{
$hash = $manager->encode(1, 2, 3);
$client = \support\Container::instance()->get(Hashids::class);
$hash2 = $client->encode(4);
return json(['hash' => $hash, 'hash2' => $hash2]);
}
}