PHP code example of icanhazstring / expressive-hashids-middleware

1. Go to this page and download the library: Download icanhazstring/expressive-hashids-middleware 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/ */

    

icanhazstring / expressive-hashids-middleware example snippets


$attributes = $request->getAttributes();

/*
[
    'id' => 'ABC',
    '__hashids_identifier' => 1
]
*/

$aggregator = new ConfigAggregator([
    ...
    \icanhazstring\Hashids\HashidsConfigProvider::class,
    ...
]);

return [
    \icanhazstring\Hashids\HashidsConfigProvider::CONFIG_KEY => [
        'salt'                 => '',
        'minHashLength'        => 0,
        'alphabet'             => 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890',
        'resource_identifiert' => 'id'
    ]
];

class ConfigProvider
{
    public function __invoke(): array
    {
        return [
            'hydrators' => [
                'delegators' => [
                    ArraySerializable::class => [
                        \icanhazstring\Hashids\Hydrator\HashidsHydratorDelegatorFactory:class
                    ]
                ]
            ],
        ];
    }
}