Download the PHP package kode/http-client without Composer

On this page you can find all versions of the php package kode/http-client. 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 http-client

kode/http-client

一个现代化、高性能的 PHP HTTP 客户端,支持多运行时环境(FPM、CLI、Swoole、Swow、Fiber)。

特性

安装

快速开始

基本使用

使用 Fiber 驱动

使用配置选项

驱动支持

运行环境 推荐驱动 说明
Fiber 环境 FiberDriver PHP 8.3+ 原生 Fiber 支持,自动协程切换
Swoole 协程 SwooleDriver 高性能、原生协程支持
Amp 环境 AmpDriver 基于事件循环的异步实现
默认环境 CurlDriver 基于 curl 扩展的同步实现

驱动选择优先级

自动模式下,驱动选择优先级为:

  1. SwooleDriver - 如果在 Swoole 协程环境中
  2. FiberDriver - 如果 PHP 8.3+ 且 curl 扩展可用
  3. AmpDriver - 如果 Amp HTTP 客户端可用
  4. CurlDriver - 默认回退

手动选择驱动

中间件

认证中间件

支持 Bearer Token 和 API Key 认证:

限流中间件

使用令牌桶算法实现请求频率限制:

缓存中间件

自动缓存 GET 请求响应:

重试中间件

支持指数退避策略的自动重试:

超时中间件

为请求设置超时时间:

日志中间件

记录请求和响应信息:

链路追踪中间件

基于 kode/context 3.x 的 toHeaders() / fromHeaders(),自动把当前链路上下文 (W3C traceparent / tracestate 以及 X-Context-* 私有头)注入出站请求, 打通跨服务全链路追踪:

开启链路追踪需在请求前调用 Kode\Context\Context::startTrace()(或复用已有链路); 未开启时仍会透传已存在的 X-Context-* 头(如请求 ID、关联 ID),但不会注入 W3C 头。 可通过工厂一键启用:

上下文管理

使用 kode/context 进行上下文传递:

与 kode/fibers 集成

本包支持与 kode/fibers 包无缝集成:

异常处理

项目结构

示例

example/ 下提供了可直接运行的示例:

文件 说明 联网
example/quickstart.php 基础用法:GET/POST、JSON/表单、base_uri、单次超时 需要
example/middleware.php 中间件装配、自定义中间件、各中间件运行时状态 不需要
example/concurrent.php sendConcurrent() / pool() 的「全部落定」语义 不需要
example/tracing.php 链路追踪头注入与安全降级 不需要

不联网的示例使用桩驱动(实现 DriverInterface),结果确定,也是单元测试的惯用写法。

测试

要求

可选依赖

许可证

MIT

作者

Kode Team [email protected]


All versions of http-client with dependencies

PHP Build Version
Package Version
Requires php Version ^8.3
ext-json Version *
kode/context Version ^3.1
psr/http-client Version ^1.0
psr/http-factory Version ^1.0
psr/http-message Version ^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 kode/http-client contains the following files

Loading the files please wait ...