torann/hashids
Composer 安装命令:
composer require torann/hashids
包简介
Laravel package for Hashids
README 文档
README
This package uses the classes created by hashids.org
Generate hashes from numbers, like YouTube or Bitly. Use hashids when you do not want to expose your database ids to the user.
Installation
Composer
From the command line run:
$ composer require torann/hashids
Without Package Auto-Discovery
Once Hashids is installed you need to register the service provider and facade with the application. Open up config/app.php and find the providers and aliases keys.
'providers' => [ Torann\Hashids\HashidsServiceProvider::class, ] 'aliases' => [ 'Hashids' => Torann\Hashids\Facade\Hashids::class, ]
Publish the configurations
Run this on the command line from the root of your project:
$ php artisan vendor:publish --provider="Torann\Hashids\HashidsServiceProvider"
A configuration file will be publish to config/hashids.php.
Usage
Once you've followed all the steps and completed the installation you can use Hashids.
Encoding
You can simply encode a single id:
Hashids::encode(1); // Returns Ri7Bi
or multiple..
Hashids::encode(1, 21, 12, 12, 666); // Returns MMtaUpSGhdA
Decoding
Hashids::decode(Ri7Bi); // Returns array (size=1) 0 => int 1
or multiple..
Hashids::decode(MMtaUpSGhdA); // Returns array (size=5) 0 => int 1 1 => int 21 2 => int 12 3 => int 12 4 => int 666
All credit for Hashids goes to Ivan Akimov (@ivanakimov), thanks to for making it!
torann/hashids 适用场景与选型建议
torann/hashids 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 342.75k 次下载、GitHub Stars 达 54, 最近一次更新时间为 2014 年 01 月 24 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「hash」 「encode」 「decode」 「laravel」 「hashid」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 torann/hashids 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 torann/hashids 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 torann/hashids 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
AMWSCAN (Antimalware Scanner) is a php antimalware/antivirus scanner console script written in php for scan your project. This can work on php projects and a lot of others platform.
Encode integer IDs using a preset or customized symbol set
Runn Me! Serialization Library
Article CSS-ID Frontend Output Optimization
♺ Laravel Nova Hashids card. Convert your ids.
With the JSON codec you will be able to encode into and decode from JSON data in an object oriented way. It wraps PHP's functions `json_encode()` and `json_decode()`.
统计信息
- 总下载量: 342.75k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 54
- 点击次数: 17
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: BSD-2-Clause
- 更新时间: 2014-01-24