PHPackages                             jarod2011/simple-concurrent-request-client - 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. jarod2011/simple-concurrent-request-client

ActiveLibrary

jarod2011/simple-concurrent-request-client
==========================================

一个基于guzzlehttp实现的并发请求的客户端，通过此终端可以完成并发去请求多个接口并统一拿到返回结果

1.1.2(3y ago)1511MITPHP

Since Sep 6Pushed 3y ago1 watchersCompare

[ Source](https://github.com/jarod2011/SimpleConcurrentRequestClient)[ Packagist](https://packagist.org/packages/jarod2011/simple-concurrent-request-client)[ RSS](/packages/jarod2011-simple-concurrent-request-client/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (1)Versions (5)Used By (0)

SimpleConcurrentRequestClient
=============================

[](#simpleconcurrentrequestclient)

[![GitHub license](https://camo.githubusercontent.com/7f53124c9c96078cb478f08848276060b1505151b0451c95bb2f403be4a2bffc/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f6a61726f64323031312f53696d706c65436f6e63757272656e7452657175657374436c69656e742e737667)](https://github.com/jarod2011/SimpleConcurrentRequestClient/blob/master/LICENSE)

[SimpleConcurrentRequestClient](https://packagist.org/packages/jarod2011/simple-concurrent-request-client)是一个针对[guzzle](https://github.com/guzzle/guzzle/)做的简单封装，可以很方便简单的实现多个接口调用请求并发执行并方便的获取每个调用结果。

#### 安装

[](#安装)

```
composer require jarod2011/simple-concurrent-request-client
```

#### 版本记录

[](#版本记录)

版本v1.1.1 临时修复一个bug，为当前最新版本，建议更新到此版本，此版本修复了在`RequestClient`中配置的`header`、`user-agent`等参数不能在并发请求中生效，修复后，可以通过`RequestClient`中统一配置`header`中的参数了，并增加了一个`setPromise`方法，可以直接传入一个`Promise`，而若使用了此方法则setRequest方法提供的请求将无效

版本v1.1 增加了针对https是否校验的方法，以及一个自定义client配置的方法

#### 对于以下应用场景，比较适合

[](#对于以下应用场景比较适合)

- 很多http接口需要调用，并且每个接口的调用对其他接口调用结果没有依赖性
- 多种三方接口调用，每种接口有不同的处理逻辑

#### 一个简单的应用场景

[](#一个简单的应用场景)

```
use SimpleConcurrent\SimpleRequest;
use SimpleConcurrent\RequestClient;
use GuzzleHttp\Psr7\Request;

/* 创建一个请求并使用自动的json格式转化 */
$req1 = new SimpleRequest();
$req1->setRequest(new Request('GET', 'https://photo.home.163.com/api/designer/pc/home/index/word'))->responseIsJson();

/* 初始化客户端 */
$client = new RequestClient();

/* 传入请求 */
$client->addRequest($req1);

/* 执行传入的所有请求，当前只有一个 */
$client->promiseAll();

/* 打印结果, 将返回是一个数组 */
var_dump($req1->getResponse()->getResult());
```

#### 多个请求同时调用

[](#多个请求同时调用)

```
use SimpleConcurrent\SimpleRequest;
use SimpleConcurrent\RequestClient;
use GuzzleHttp\Psr7\Request;

/* 创建几个请求 */

/* 创建一个请求并使用自动的json格式转化 */
$req1 = new SimpleRequest();
$req1->setRequest(new Request('GET', 'https://photo.home.163.com/api/designer/pc/home/index/word'))->responseIsJson();
/* 创建一个请求但不使用自动的json格式转化 */
$req2 = new SimpleRequest();
$req2->setRequest(new Request('GET', 'https://photo.home.163.com/api/designer/pc/home/index/word'));
/* 创建一个不存在的URL请求 */
$reqError = new SimpleRequest();
$reqError->setRequest(new Request('GET', 'https://www.baidu.com/notexits'));

/* 初始化客户端 */
$client = new RequestClient();

/* 传入请求 */
$client->addRequest($req1)->addRequest($req2)->addRequest($reqError);

/* 并发调用 */
$client->promiseAll();

/* 打印结果, 请求1，将返回是一个数组 */
var_dump($req1->getResponse()->getResult());

/* 打印结果，请求2，将返回是字符串 */
var_dump($req2->getResponse()->getResult());

/* 打印结果，请求3为失败,结果为null */
var_dump($reqError->getResponse()->isFail(), $reqError->getResponse()->getResult());

/* 获取失败原因 */
$failedReason = $reqError->getResponse()->getFail();

/* 查看失败的结果类型 */

/* 客户端默认不会处理错误，将会把抛出的异常赋值给响应的错误结果 */
if (is_object($failedReason)) {
    var_dump(get_class($failedReason));

    /* 如果是连接错误，将可以通过getCode获取到http code */
    if ($failedReason instanceof ClientException) {
        var_dump($failedReason->getCode());
    }
} else {
    var_dump($failedReason);
}
```

###  Health Score

29

—

LowBetter than 60% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity65

Established project with proven stability

 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.

###  Release Activity

Cadence

Every ~455 days

Total

4

Last Release

1436d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/492399afeab32200cc961b8a25da417a893595d2062e11cfb9cdfef6b14bcff3?d=identicon)[xinghen249@gmail.com](/maintainers/xinghen249@gmail.com)

---

Top Contributors

[![jarod2011](https://avatars.githubusercontent.com/u/12403856?v=4)](https://github.com/jarod2011 "jarod2011 (15 commits)")

### Embed Badge

![Health badge](/badges/jarod2011-simple-concurrent-request-client/health.svg)

```
[![Health](https://phpackages.com/badges/jarod2011-simple-concurrent-request-client/health.svg)](https://phpackages.com/packages/jarod2011-simple-concurrent-request-client)
```

###  Alternatives

[neuron-core/neuron-ai

The PHP Agentic Framework.

1.8k245.3k20](/packages/neuron-core-neuron-ai)[tencentcloud/tencentcloud-sdk-php

TencentCloudApi php sdk

3731.2M42](/packages/tencentcloud-tencentcloud-sdk-php)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

255.2k](/packages/aedart-athenaeum)

PHPackages © 2026

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