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.

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 hyperf-sdk

抖店开放平台 PHP SDK for Hyperf

PHP Version Hyperf Version

这是一个专为 Hyperf 框架优化的抖店开放平台 PHP SDK,支持协程并发、依赖注入、连接池等 Hyperf 特性。

特性

安装

配置

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 规范 部分 完全遵循

性能优化建议

  1. 使用连接池: 在高并发场景下,合理配置连接池参数
  2. 缓存访问令牌: 访问令牌有效期较长,建议缓存避免频繁获取
  3. 批量请求: 利用协程特性并发调用多个 API
  4. 错误重试: 对于网络错误,建议实现重试机制

常见问题

Q: 如何处理访问令牌过期?

A: 检查响应中的错误码,如果是令牌过期相关错误,使用刷新令牌重新获取:

Q: 如何在不同的 Shop 之间切换?

A: 在配置文件中定义多个应用,然后通过名称获取对应的客户端:

Q: 如何调试 API 请求?

A: 可以在 Hyperf 日志配置中增加 Guzzle 的请求日志:

许可证

MIT License. 详见 LICENSE 文件。

贡献

欢迎提交 Issue 和 Pull Request!

更新日志

v1.0.0


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
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 doudian/hyperf-sdk contains the following files

Loading the files please wait ....