NOTE: The master branch for 2.0 version, that require mini php version is 5.6. You can require light/hashids:^1.0
to use old version.
Install this package via Composer:
$ composer require light/hashids=^2.0
In your main.php
or web.php
(dependences your yii2 project constructor):
[
'hahsids' => [
'class' => 'light\hashids\Hashids',
//'salt' => 'your salt',
//'minHashLength' => 5,
//'alphabet' => 'abcdefghigk'
]
]
Also using this like this:
$hashids = Yii::createObject([
'class' => 'light\hashids\Hashids'
]);
$id = $hashids->encode(1, 2, 3);
$numbers = $hashids->decode($id);
var_dump($id, $numbers);
$ phpunit