PHP code example of trianity / laravel-sqids

1. Go to this page and download the library: Download trianity/laravel-sqids 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/ */

    

trianity / laravel-sqids example snippets


return [
    'minLength' => 12,
    'alphabet' => 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890',
    'blocklist' => [
        // 'word',
    ],
];

use Trianity\Sqids\Facades\Sqids;

$id = Sqids::encode([4815162342]);

$numbers = Sqids::decode($id);

use Trianity\Sqids\SqidsFactory;

final class LinkController
{
    public function show(SqidsFactory $sqids, string $id): array
    {
        return $sqids->decode($id);
    }
}

use Trianity\Sqids\SqidsFactory;

$sqids = new SqidsFactory(minLength: 24);

$id = $sqids->encode([1, 2, 3]);
bash
php artisan vendor:publish --provider="Trianity\Sqids\Providers\PackageServiceProvider"
bash
php artisan vendor:publish --tag=config-sqids