PHPackages                             network/http - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [HTTP &amp; Networking](/categories/http)
4. /
5. network/http

ActiveLibrary[HTTP &amp; Networking](/categories/http)

network/http
============

一款基于PHP的轻量级HTTP网络请求库

051PHP

Since May 29Pushed 11mo ago1 watchersCompare

[ Source](https://github.com/xh8039/php-net-request)[ Packagist](https://packagist.org/packages/network/http)[ RSS](/packages/network-http/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

轻HTTP请求库使用文档
============

[](#轻http请求库使用文档)

> 觉得本项目不错的话可以帮忙点一下星星Star哦

简介
--

[](#简介)

轻HTTP请求库是一个简单轻量的PHP HTTP客户端,用于发送各种HTTP请求。它支持GET、POST、HEAD、DELETE、PUT、PATCH等方法,可以轻松发送JSON、XML等格式的数据。

```
$client = new Client();
$response = $client->get('http://www.example.com');
echo $response; // 输出响应体
```

该库的主要特性:

- 支持主流的HTTP方法：GET、POST、HEAD、DELETE、PUT、PATCH 等。可以发送各种请求，获取不同的响应。
- 支持URL参数、请求体、请求头、Cookie等设置。可以定制灵活的请求参数。
- 发送请求体支持JSON、XML、文本等格式。支持的请求数据类型丰富。
- 简单易用,代码量小巧轻量，使用方法灵活。接口简单明了,学习成本低。
- 基于PHP原生curl扩展，性能高效稳定。利用curl实现,性能优秀。

安装
--

[](#安装)

### 通过 Composer 安装

[](#通过-composer-安装)

#### 1. 安装 Composer

[](#1-安装-composer)

```
curl -sS https://getcomposer.org/installer | php
```

#### 2. 运行安装命令

[](#2-运行安装命令)

```
composer require network/http:dev-master
```

#### 3. 启用 Composer 自动加载

[](#3-启用-composer-自动加载)

```
require 'vendor/autoload.php';
```

启用后,可直接使用 `$client = new Client();`

基本使用
----

[](#基本使用)

```
use network\http\Client;

$client = new Client();

$client->param('name', '易航'); // 设置请求参数

$client->header('User-Agent', 'Mozilla/5.0'); // 设置请求头

$response = $client->get('http://www.bri6.cn'); // 发送GET请求

echo $response; // 输出响应体
```

请求参数用于构造请求URL的参数,请求头用于定制客户端信息，发起GET请求后获取响应，并输出响应体。

详情见 [基本使用页面](readme/%E5%9F%BA%E6%9C%AC%E4%BD%BF%E7%94%A8.md)。

助手函数
----

[](#助手函数)

详情见 [助手函数页面](readme/%E5%8A%A9%E6%89%8B%E5%87%BD%E6%95%B0.md)。

获取响应信息
------

[](#获取响应信息)

详情见 [获取响应页面](readme/%E8%8E%B7%E5%8F%96%E5%93%8D%E5%BA%94.md)。

显示响应体
-----

[](#显示响应体)

详情见 [显示响应体页面](readme/%E6%98%BE%E7%A4%BA%E5%93%8D%E5%BA%94%E4%BD%93.md)。

错误与异常
-----

[](#错误与异常)

详情见 [错误与异常页面](readme/%E9%94%99%E8%AF%AF%E4%B8%8E%E5%BC%82%E5%B8%B8.md)。

其他
--

[](#其他)

另外,如果需要对请求库进行定制开发，可以继承Client类并重写send()方法：

```
namespace network\http;

class CustomClient extends Client
{
    public function send($url, $params, $headers)
    {
        // 定制发送请求的逻辑
        // 调用parent::send($url, $params, $headers)发送请求
    }
}
```

然后通过 `new CustomClient()` 使用定制的客户端。

希望这个HTTP客户端库和使用文档能为您提供帮助！如果有任何问题请提Issue或Pull Request。

我会持续更新文档，完整记录轻HTTP请求库的所有功能和用法。如果文档的任何部分不够详尽，请提Issue告知我。

希望这个简洁实用的轻HTTP请求库和配套文档能为广大PHP开发者提供更多便捷！

###  Health Score

17

—

LowBetter than 6% of packages

Maintenance37

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity14

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/9dc9fc9120c3cf12251aca7285bda86989fa6f5efcb446b7337098fb72c3936c?d=identicon)[xh8039](/maintainers/xh8039)

---

Top Contributors

[![xh8039](https://avatars.githubusercontent.com/u/89853736?v=4)](https://github.com/xh8039 "xh8039 (46 commits)")

### Embed Badge

![Health badge](/badges/network-http/health.svg)

```
[![Health](https://phpackages.com/badges/network-http/health.svg)](https://phpackages.com/packages/network-http)
```

###  Alternatives

[friendsofsymfony/rest-bundle

This Bundle provides various tools to rapidly develop RESTful API's with Symfony

2.8k73.3M319](/packages/friendsofsymfony-rest-bundle)[php-http/discovery

Finds and installs PSR-7, PSR-17, PSR-18 and HTTPlug implementations

1.3k309.5M1.2k](/packages/php-http-discovery)[pusher/pusher-php-server

Library for interacting with the Pusher REST API

1.5k94.8M293](/packages/pusher-pusher-php-server)[react/http

Event-driven, streaming HTTP client and server implementation for ReactPHP

78026.4M414](/packages/react-http)[php-http/curl-client

PSR-18 and HTTPlug Async client with cURL

48347.0M384](/packages/php-http-curl-client)[smi2/phpclickhouse

PHP ClickHouse Client

84310.1M71](/packages/smi2-phpclickhouse)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
