Download the PHP package erikwang2013/hashids without Composer

On this page you can find all versions of the php package erikwang2013/hashids. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package hashids

erikwang2013/hashids

PHP 多框架 Hashids 集成:LaravelWebmanThinkPHPHyperf。参考来源、配置与用法对齐 vinkla/hashids(多连接、默认连接、HashidsManager + 工厂)。

底层依赖:hashids/hashids v5。

项目说明

Hashids 是一款短 ID 生成器,可将数字 ID(如数据库主键)编码为短小、唯一且不可猜测的字符串。它不同于 UUID 或雪花 ID——Hashids 更适合用于面向用户的场景(URL、分享码、订单号等),在保持短小可读的同时隐藏原始数字。

本包 erikwang2013/hashids 是 Hashids 的 PHP 多框架集成层,在设计上参考并对齐了 vinkla/hashids 的 API 风格(多连接、默认连接、Manager + Factory 模式),并扩展支持了国内常用的其他 PHP 框架。

核心特性:

适用场景:

场景 说明
隐藏数据库自增 ID user_id=100 映射为 /user/3kTMd,避免暴露业务规模
生成短链接/分享码 比 UUID 更短,比随机字符串可控
订单号/流水号 可读性好,便于客服沟通与日志排查
多租户/多模块隔离 不同连接使用不同 Salt,确保编码空间相互独立

注意事项:

安装

配置结构(Laravel / Webman / ThinkPHP)

与仓库 config/hashids.php 一致:

Hyperf 使用单独的配置文件格式(外层键为 hashids),见下文 Hyperf 小节。

无框架用法

可直接实例化管理器:


Laravel

vinkla/hashids 类似:容器注册 HashidsManager,多连接;默认连接支持 Facade 与方法转发。

Laravel 5.5+ 会读取本包 composer.jsonextra.laravel,自动注册 HashidsServiceProvider 与 Facade 别名 Hashids

发布配置(可选)

生成 config/hashids.php。若不发布,扩展包会在注册阶段合并内置默认配置。

Facade(默认连接)

指定连接

依赖注入 HashidsManager

注入底层 Hashids\Hashids(默认连接)

运行 Laravel 集成需要项目已安装 laravel/framework(含 illuminate/support 等)。本包将 illuminate/* 列为 require-dev,仅供包自身测试。


Webman

通过 Install 在安装时拷贝 config/plugin/erikwang2013/hashids 与根目录 config/hashids.php,并由插件 bootstrap 向 Webman 容器注册 HashidsManager

项目的 composer.json 中若已有 support\Plugin::install / update / uninstall 钩子,安装本包时会自动执行安装脚本(WEBMAN_PLUGIN = true)。

安装后文件

若自动拷贝未执行,可从扩展包内手动复制上述路径的示例配置。

关闭插件config/plugin/erikwang2013/hashids/app.php

容器绑定

控制器示例

指定连接

Composer 卸载包时会触发 Plugin::uninstall,移除 config/plugin/erikwang2013/hashids不会删除 config/hashids.php,是否保留由你决定。


ThinkPHP

通过 自定义服务类 注册 HashidsManager;配置仍为顶层含 defaultconnectionsconfig/hashids.php

注册服务

在应用 config/service.php(具体路径随 TP 版本可能不同)的 services 中加入:

若使用应用级 app/AppService.php,也可在 register() 中写入等价绑定。

配置文件

将扩展包内 config/hashids.php 复制到应用 config/hashids.php(或自行合并同名配置)。

使用示例

ThinkPHP 集成继承 think\Service,需在 topthink/framework 环境中使用(本包列为 suggest)。


Hyperf

Composer extra.hyperf.config 会载入 ConfigProvider,向容器注册 HashidsFactoryHashidsManager、默认连接的 Hashids\Hashids

将扩展包内 config/autoload/hashids.php 复制到项目 config/autoload/hashids.php(或使用项目的配置发布命令)。

该文件须满足:顶层键 hashids,供 ConfigInterface::get('hashids') 读取。

容器绑定

抽象 实现
Erikwang2013\Hashids\HashidsFactory 默认构造
Erikwang2013\Hashids\HashidsManager HashidsManagerFactory
Hashids\Hashids HashidsClientFactory(默认连接)

Controller / 构造函数注入

Hyperf 使用 config/autoload/hashids.php 且配置套在 hashids 键下;Laravel / Webman / ThinkPHP 使用扁平结构(根级 default + connections)。请勿混用格式。


开源不易,欢迎支持

微信 支付宝

License

MIT. See LICENSE.


All versions of hashids with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
hashids/hashids Version ^5.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package erikwang2013/hashids contains the following files

Loading the files please wait ...