PHPackages                             api-clients/transport - 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. api-clients/transport

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

api-clients/transport
=====================

Middleware infused clue/buzz-react

3.2.0(7y ago)495.3k↓46%3[4 PRs](https://github.com/php-api-clients/transport/pulls)9MITPHPPHP ^7.0

Since Nov 12Pushed 2y ago4 watchersCompare

[ Source](https://github.com/php-api-clients/transport)[ Packagist](https://packagist.org/packages/api-clients/transport)[ RSS](/packages/api-clients-transport/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (6)Dependencies (7)Versions (21)Used By (9)

API Client Transport for PHP 7.x
================================

[](#api-client-transport-for-php-7x)

[![Build Status](https://camo.githubusercontent.com/b22217fbf73127b22a94f8e81fe87259128dc911e4fcdf85f6f59fab40a96a6a/68747470733a2f2f7472617669732d63692e6f72672f7068702d6170692d636c69656e74732f7472616e73706f72742e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/php-api-clients/transport)[![Latest Stable Version](https://camo.githubusercontent.com/7a291f755d9c09eb2390d79bd957cf3cba307a5a9b01f5d7cfa0a66b2a7f6568/68747470733a2f2f706f7365722e707567782e6f72672f6170692d636c69656e74732f7472616e73706f72742f762f737461626c652e706e67)](https://packagist.org/packages/api-clients/transport)[![Total Downloads](https://camo.githubusercontent.com/4aebc125157bc2a63ac5b01c650c1e77ed24cf7a11fdf7889563ce4fc5a5b1ce/68747470733a2f2f706f7365722e707567782e6f72672f6170692d636c69656e74732f7472616e73706f72742f646f776e6c6f6164732e706e67)](https://packagist.org/packages/api-clients/transport/stats)[![Code Coverage](https://camo.githubusercontent.com/21b62b602e34b0d547c4cbdd217ead87feb91a0ba3a302df2eb94a8a44bd1502/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f7068702d6170692d636c69656e74732f7472616e73706f72742f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/php-api-clients/transport/?branch=master)[![License](https://camo.githubusercontent.com/19054f7988e285f25cf8355769ac47243dcd55ba84d0cbd2e588992d893e57cf/68747470733a2f2f706f7365722e707567782e6f72672f6170692d636c69656e74732f7472616e73706f72742f6c6963656e73652e706e67)](https://packagist.org/packages/api-clients/transport)[![PHP 7 ready](https://camo.githubusercontent.com/20c55d7877c0a9b146711aaf7f57397a228fd6364ffe3e9078e38a6e992bfc32/687474703a2f2f7068703772656164792e74696d6573706c696e7465722e63682f7068702d6170692d636c69656e74732f7472616e73706f72742f62616467652e737667)](https://appveyor-ci.org/php-api-clients/transport)

In a nutshell this package is a wrapper around `clue/buzz-react` adding [middleware](https://github.com/php-api-clients/middleware).

Install
=======

[](#install)

To install via [Composer](http://getcomposer.org/), use the command below, it will automatically detect the latest version and bind it with `^`.

```
composer require api-clients/transport

```

Usage
=====

[](#usage)

Creating the client can be done using the factory:

```
$locator = new MiddlewareLocator(); // A concrete class implementing the middleware locator interface
$loop = EventLoopFactory::create(); // The event loop
$options = []; // Client options, as described below
$client = Factory::create($locator, $loop, $options);
```

Next you can make PSR-7 request:

```
$request = new PsrRequest(); //
$requestOptions = []; // Options such as middleware settings
$client->request($request, $requestOptions)->done(function (ResponseInterface $response) {
    // Handle the response
});
```

Middleware
==========

[](#middleware)

Middlewares are passed into the client with the options argument. In this example the [`api-clients/middleware-delay`](https://github.com/php-api-clients/middleware-delay) is used. Adding middlewares to the client is simple, add an array to `$options` with `Options::MIDDLEWARE` as index cosisting of middleware class names. Optionally you can pass options for the middleware through the `$options` array. Simply add a new array inside the array with the middlware class name as index and pass the desired options into it.

```
$options = [
    Options::DEFAULT_REQUEST_OPTIONS => [
        \ApiClients\Middleware\Delay\DelayMiddleware::class => [
            \ApiClients\Middleware\Delay\Options::DELAY => 3,
        ],
    ],
    Options::MIDDLEWARE => [
        \ApiClients\Middleware\Delay\DelayMiddleware::class,
    ],
];

$client = new Client($loop, $container, $browser, $options);
```

Middleware options can be changed per request, this specific request only will have a delay of 5 seconds instead of the default 3:

```
$requestOptions = [
    \ApiClients\Middleware\Delay\DelayMiddleware::class => [
        \ApiClients\Middleware\Delay\Options::DELAY => 5,
    ],
];
$client->request($request, $requestOptions);
```

Options
=======

[](#options)

Options::DNS
------------

[](#optionsdns)

DNS server to use resolving hostnames, defaults to `8.8.8.8`.

Options::SCHEMA
---------------

[](#optionsschema)

Schema part of the URI, defaults to `https`.

Options::HOST
-------------

[](#optionshost)

Host part of the URI, required.

Options::PORT
-------------

[](#optionsport)

Port part of the URI, optional.

Options::PATH
-------------

[](#optionspath)

Path part of the URI, defaults to `/`.

Options::HEADERS
----------------

[](#optionsheaders)

Key value array with headers, defaults to `[]`.

Options::MIDDLEWARE
-------------------

[](#optionsmiddleware)

Array with middleware class names, for example `[MiddlewareOne::class, MiddlewareTwo::class]`, defaults to `[]`.

Options::DEFAULT\_REQUEST\_OPTIONS
----------------------------------

[](#optionsdefault_request_options)

Set of default request options, mainly useful for middlewares needed for all requests, defaults to `[]`.

License
=======

[](#license)

The MIT License (MIT)

Copyright (c) 2017 Cees-Jan Kiewiet

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

###  Health Score

39

—

LowBetter than 84% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity34

Limited adoption so far

Community27

Small or concentrated contributor base

Maturity67

Established project with proven stability

 Bus Factor1

Top contributor holds 90.7% 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 ~48 days

Recently: every ~73 days

Total

10

Last Release

2917d ago

Major Versions

1.0.1 → 2.0.02017-07-04

2.0.0 → 3.0.02017-07-22

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/147145?v=4)[Cees-Jan Kiewiet](/maintainers/WyriHaximus)[@WyriHaximus](https://github.com/WyriHaximus)

---

Top Contributors

[![WyriHaximus](https://avatars.githubusercontent.com/u/147145?v=4)](https://github.com/WyriHaximus "WyriHaximus (350 commits)")[![dependabot-support](https://avatars.githubusercontent.com/u/112581971?v=4)](https://github.com/dependabot-support "dependabot-support (16 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (12 commits)")[![jaapio](https://avatars.githubusercontent.com/u/1060433?v=4)](https://github.com/jaapio "jaapio (2 commits)")[![ivailo-stoianov](https://avatars.githubusercontent.com/u/5235174?v=4)](https://github.com/ivailo-stoianov "ivailo-stoianov (2 commits)")[![mdrost](https://avatars.githubusercontent.com/u/4083346?v=4)](https://github.com/mdrost "mdrost (1 commits)")[![scrutinizer-auto-fixer](https://avatars.githubusercontent.com/u/6253494?v=4)](https://github.com/scrutinizer-auto-fixer "scrutinizer-auto-fixer (1 commits)")[![VarCI-bot](https://avatars.githubusercontent.com/u/17718013?v=4)](https://github.com/VarCI-bot "VarCI-bot (1 commits)")[![veewee](https://avatars.githubusercontent.com/u/1618158?v=4)](https://github.com/veewee "veewee (1 commits)")

---

Tags

api-clienthacktoberfestmiddlewarephpphp7reactphptransport

### Embed Badge

![Health badge](/badges/api-clients-transport/health.svg)

```
[![Health](https://phpackages.com/badges/api-clients-transport/health.svg)](https://phpackages.com/packages/api-clients-transport)
```

###  Alternatives

[friendsofphp/php-cs-fixer

A tool to automatically fix PHP code style

13.5k251.2M25.3k](/packages/friendsofphp-php-cs-fixer)[cboden/ratchet

PHP WebSocket library

6.4k22.3M254](/packages/cboden-ratchet)[react/http

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

78127.7M466](/packages/react-http)[gos/web-socket-bundle

Symfony Web Socket Bundle

6202.2M8](/packages/gos-web-socket-bundle)[team-reflex/discord-php

An unofficial API to interact with the voice and text service Discord.

1.1k420.9k26](/packages/team-reflex-discord-php)[rector/rector-src

Instant Upgrade and Automated Refactoring of any PHP code

136406.3k14](/packages/rector-rector-src)

PHPackages © 2026

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