nblackburn/laravel-hashids
最新稳定版本:1.2.4
Composer 安装命令:
composer require nblackburn/laravel-hashids
包简介
A hashids wrapper for Laravel and Lumen.
README 文档
README
A hashids wrapper for Laravel & Lumen.
Installation
Laravel
Inside config/app.php add the following line in your providers
LaravelHashids\Providers\LaravelServiceProvider::class
and then simply run the following artisan command...
php artisan config:publish nblackburn/laravel-hashids
Facade
To add facade support for Laravel, add the following line inside your config/app.php under the alias section...
'Parsedown' => LaravelParsedown\Facades\Parsedown::class,
Lumen
Inside bootstrap/app.php, add the following line:
$app->register(LaravelHashids\Providers\LumenServiceProvider::class);
then add the following to your .env file:
# HASHIDS HASHIDS_SALT = YOURSECRETKEY HASHIDS_LENGTH = 8 HASHIDS_ALPHABET = abcedfghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPAQRSTUVWXYZ1234567890
Facade
To add facade support, firstly uncomment the following line within bootstrap/app.php:
// $app->withFacades();
then register the facade like so...
$app->register(LaravelHashids\Facades\Hashids::class);
Settings
| name | description | default |
|---|---|---|
| salt | The secret used for hashing. | MYREALLYSECRETSALT |
| length | The maximum length of the hash. | 10 |
| alphabet | The characters used for hashing. | abcedefghijklmnopqrstuvwxyzABCEDEFGHIJKLMNOPQRSTUVWXYZ123456890 |
Usage
Encode
Encode a series of integers
app('hashids')->encode(...$integers);
or with the facade
Hashids::encode(...$integers);
Decode
Decode a encoded string back to the original integers
app('hashids')->decode($encoded);
or with the facade
Hashids::decode($encoded);
License
This library is licensed under MIT, see license.md for details.
Donations
统计信息
- 总下载量: 14.39k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 9
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: mit
- 更新时间: 2016-01-11