PHPackages                             jwh0968/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. [HTTP &amp; Networking](/categories/http)
4. /
5. jwh0968/simple-concurrent-request-client

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

jwh0968/simple-concurrent-request-client
========================================

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

1.1.2(5y ago)012MITPHP

Since Mar 15Pushed 5y agoCompare

[ Source](https://github.com/hjw0968/SimpleConcurrentRequestClient)[ Packagist](https://packagist.org/packages/jwh0968/simple-concurrent-request-client)[ RSS](/packages/jwh0968-simple-concurrent-request-client/feed)WikiDiscussions master Synced 4w ago

READMEChangelog (1)Dependencies (1)Versions (2)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 jwh0968/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', 'http://developerhome.net/json/test.json'))->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', 'http://developerhome.net/json/test.json'))->responseIsJson();
/* 创建一个请求但不使用自动的json格式转化 */
$req2 = new SimpleRequest();
$req2->setRequest(new Request('GET', 'http://developerhome.net/json/test1.json'));
/* 创建一个不存在的URL请求 */
$reqError = new SimpleRequest();
$reqError->setRequest(new Request('GET', 'http://developerhome.net/json/no_exists_file'));

/* 初始化客户端 */
$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

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity52

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 76.5% 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

Unknown

Total

1

Last Release

1881d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/98a7591de2b3233853473d06310d6233d953ba5ac9d2314f9416021476a8cba7?d=identicon)[jwh0968](/maintainers/jwh0968)

---

Top Contributors

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

### Embed Badge

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

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

###  Alternatives

[spatie/crawler

Crawl all internal links found on a website

2.8k16.3M52](/packages/spatie-crawler)[omniphx/forrest

A Laravel library for Salesforce

2724.4M8](/packages/omniphx-forrest)[akamai-open/edgegrid-client

Implements the Akamai {OPEN} EdgeGrid Authentication specified by https://developer.akamai.com/introduction/Client\_Auth.html

482.5M6](/packages/akamai-open-edgegrid-client)[sunchayn/nimbus

A Laravel package providing an in-browser API client with automatic schema generation, live validation, and built-in authentication with a touch of Laravel-tailored magic for effortless API testing.

29428.0k](/packages/sunchayn-nimbus)[muhammadhuzaifa/telescope-guzzle-watcher

Telescope Guzzle Watcher provide a custom watcher for intercepting http requests made via guzzlehttp/guzzle php library. The package uses the on\_stats request option for extracting the request/response data. The watcher intercept and log the request into the Laravel Telescope HTTP Client Watcher.

98239.8k1](/packages/muhammadhuzaifa-telescope-guzzle-watcher)[onesignal/onesignal-php-api

A powerful way to send personalized messages at scale and build effective customer engagement strategies. Learn more at onesignal.com

34170.2k2](/packages/onesignal-onesignal-php-api)

PHPackages © 2026

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