yiier/yii2-hashids

为 Yii2 定制的 Hashids

v3.0.0 2022-04-24 03:43 UTC

This package is auto-updated.

Last update: 2024-09-24 08:57:51 UTC


README

Build Status version Download Issues

安装

通过 Composer 安装此包

$ composer require yiier/yii2-hashids

用法

配置为组件

在你的 main.phpweb.php(依赖于你的 yii2 项目构造函数)中

[
	'hahsids' => [
		'class' => 'yiier\hashids\Hashids',
		//'salt' => 'your salt',
		//'minHashLength' => 5,
		//'alphabet' => 'abcdefghigk'
	]
]

也可以这样使用

$hashids = Yii::createObject([
	'class' => 'yiier\hashids\Hashids'
]);

$id = $hashids->encode(1, 2, 3);
$numbers = $hashids->decode($id);
var_dump($id, $numbers);

测试

$ phpunit

许可证

MIT