jimchen/yii2-hashids
最新稳定版本:0.1.0
Composer 安装命令:
composer require jimchen/yii2-hashids
包简介
Hashids for Yii framework
README 文档
README
Hashids for Yii framework
Installing
$ composer require jimchen/yii2-hashids -vvv
Usage
Configure application components as follows
return [ //... 'components' => [ //... 'hashids' => [ 'class' => 'jimchen\hashids\HashidsComponent', 'salt' => 'default channel salt', 'length' => 'default channel length of the encode string', // 'default' => 'main' // default channel // 'connections' => null // other channel ], ], ];
the connections should defined like:
[
...
'connections' => [
'channel name' => [
'salt' => 'the salt',
'length' => 'the length of the encode string',
],
...
]
]
Use in your code as follows(it use the default channel.)
use Yii; $encode = Yii::$app->hashids->encode(12345); var_dump(Yii::$app->hashids->decode($encode)); // [12345]
Use other channel
use Yii; $otherChannelHashids = \Yii::createObject('hashids.manager')->connection('channel name'); $encode = $otherChannelHashids->encode(12345); var_dump($otherChannelHashids->decode($encode)); // [12345]
License
MIT
统计信息
- 总下载量: 1.29k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 5
- 点击次数: 2
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2018-08-29