Download the PHP package doudian/hyperf-sdk without Composer
On this page you can find all versions of the php package doudian/hyperf-sdk. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Table of contents
Download doudian/hyperf-sdk
More information about doudian/hyperf-sdk
Files in doudian/hyperf-sdk
Download doudian/hyperf-sdk
More information about doudian/hyperf-sdk
Files in doudian/hyperf-sdk
Vendor doudian
Package hyperf-sdk
Short Description 抖店开放平台 PHP SDK for Hyperf Framework - 支持协程、依赖注入、连接池的高性能 SDK
License MIT
Homepage https://github.com/Saym-l/doudian-hyperf-sdk
Package hyperf-sdk
Short Description 抖店开放平台 PHP SDK for Hyperf Framework - 支持协程、依赖注入、连接池的高性能 SDK
License MIT
Homepage https://github.com/Saym-l/doudian-hyperf-sdk
Please rate this library. Is it a good library?
Informations about the package hyperf-sdk
抖店开放平台 PHP SDK for Hyperf
这是一个专为 Hyperf 框架优化的抖店开放平台 PHP SDK,支持协程并发、依赖注入、连接池等 Hyperf 特性。
特性
- ✅ 协程支持: 基于 Hyperf Guzzle 的协程 HTTP 客户端
- ✅ 依赖注入: 完全集成 Hyperf DI 容器
- ✅ 连接池: 支持 HTTP 连接池,提高性能
- ✅ 多应用配置: 支持同时管理多个抖店应用
- ✅ 类型安全: 使用 PHP 8+ 严格类型声明
- ✅ PSR 标准: 遵循 PSR-4 自动加载和 PSR-1 编码标准
- ✅ 零依赖冲突: 与原版 SDK 可共存
安装
配置
1. 发布配置文件
2. 编辑配置文件
编辑 config/autoload/doudian.php
:
3. 环境变量
在 .env
文件中添加:
快速开始
1. 在控制器中使用
2. 在服务类中使用
访问令牌管理
获取访问令牌
刷新访问令牌
解析已有的访问令牌
API 调用示例
产品相关 API
自定义 API 请求
如果您需要调用尚未封装的 API,可以继承 AbstractRequest
类:
错误处理
配置说明
配置项 | 类型 | 默认值 | 说明 |
---|---|---|---|
app_key |
string | - | 应用 Key(必填) |
app_secret |
string | - | 应用密钥(必填) |
open_request_url |
string | https://openapi-fxg.jinritemai.com | API 请求地址 |
http_connect_timeout |
int | 3 | 连接超时时间(秒) |
http_read_timeout |
int | 10 | 读取超时时间(秒) |
pool.min_connections |
int | 1 | 连接池最小连接数 |
pool.max_connections |
int | 10 | 连接池最大连接数 |
pool.connect_timeout |
float | 10.0 | 连接池连接超时 |
pool.wait_timeout |
float | 3.0 | 连接池等待超时 |
pool.heartbeat |
int | -1 | 心跳间隔(-1 为禁用) |
pool.max_idle_time |
float | 60.0 | 最大空闲时间 |
与原版 SDK 的区别
特性 | 原版 SDK | Hyperf SDK |
---|---|---|
HTTP 客户端 | cURL | Hyperf Guzzle (协程) |
依赖注入 | 不支持 | 完全支持 |
连接池 | 不支持 | 支持 |
多应用配置 | 不支持 | 支持 |
协程安全 | 否 | 是 |
类型声明 | 部分 | 严格类型 |
PSR 规范 | 部分 | 完全遵循 |
性能优化建议
- 使用连接池: 在高并发场景下,合理配置连接池参数
- 缓存访问令牌: 访问令牌有效期较长,建议缓存避免频繁获取
- 批量请求: 利用协程特性并发调用多个 API
- 错误重试: 对于网络错误,建议实现重试机制
常见问题
Q: 如何处理访问令牌过期?
A: 检查响应中的错误码,如果是令牌过期相关错误,使用刷新令牌重新获取:
Q: 如何在不同的 Shop 之间切换?
A: 在配置文件中定义多个应用,然后通过名称获取对应的客户端:
Q: 如何调试 API 请求?
A: 可以在 Hyperf 日志配置中增加 Guzzle 的请求日志:
许可证
MIT License. 详见 LICENSE 文件。
贡献
欢迎提交 Issue 和 Pull Request!
更新日志
v1.0.0
- 初始版本发布
- 支持 Hyperf 3.0+ 框架
- 实现协程 HTTP 客户端
- 支持依赖注入和多应用配置
All versions of hyperf-sdk with dependencies
PHP Build Version
Package Version
Requires
php Version
>=8.0
hyperf/framework Version ^3.0
hyperf/di Version ^3.0
hyperf/config Version ^3.0
hyperf/guzzle Version ^3.0
hyperf/logger Version ^3.0
hyperf/pool Version ^3.0
psr/container Version ^1.0|^2.0
hyperf/framework Version ^3.0
hyperf/di Version ^3.0
hyperf/config Version ^3.0
hyperf/guzzle Version ^3.0
hyperf/logger Version ^3.0
hyperf/pool Version ^3.0
psr/container Version ^1.0|^2.0
The package doudian/hyperf-sdk contains the following files
Loading the files please wait ....