PHPackages                             dmt-software/http-client-middleware - 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. dmt-software/http-client-middleware

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

dmt-software/http-client-middleware
===================================

HTTP client request handler

v2.0.0(1y ago)017.0k↓11.9%3MITPHPPHP &gt;=8.1

Since Mar 18Pushed 1y ago2 watchersCompare

[ Source](https://github.com/dmt-software/http-client-middleware)[ Packagist](https://packagist.org/packages/dmt-software/http-client-middleware)[ RSS](/packages/dmt-software-http-client-middleware/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (6)Versions (15)Used By (3)

Http Client Middleware
======================

[](#http-client-middleware)

Unfortunately [psr-15](https://www.php-fig.org/psr/psr-15/), the recommendation how to handle incoming server request, does not cover how to deal with an outgoing request or a client response.

This package solves that problem.

Installation
------------

[](#installation)

`composer require dmt-software/http-client-middleware`

Usage
-----

[](#usage)

```
use DMT\Http\Client\RequestHandler;
use Psr\Http\Client\ClientInterface;
use Psr\Http\Message\RequestInterface;

/** @var ClientInterface $client */
$handler = new RequestHandler($client);
$response = $handler->handle($request);

if ($response->getStatusCode() === 200) {
   // process the response
}
```

### Middleware

[](#middleware)

Middleware can be used to process a request before it is sent to the server by the client or to handle the response, for instance to apply authentication, store a login cookie or log the response.

```
use DMT\Http\Client\MiddlewareInterface;
use DMT\Http\Client\RequestHandlerInterface;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\RequestInterface;

/**
 * Apply basic authentication header to the request
 */
class BasicAuthMiddleware implements MiddlewareInterface
{
    private string $user = 'user';
    private string $pass = '*****';

    public function process(RequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
    {
        $request = $request->withHeader(
            'Authorization', sprintf('Basic %s', base64_encode("$this->user:$this->pass"))
        );

        return $handler->handle($request);
    }
}
```

To enable middleware simply add these to the request handler.

```
use DMT\Http\Client\RequestHandler;
use Psr\Http\Client\ClientInterface;
use Psr\Http\Message\RequestInterface;

/** @var ClientInterface $client */
$handler = new RequestHandler(
    $client,
    $basicAuthMiddleware,
    $otherMiddleware,
);
$response = $handler->handle($request);
```

###  Health Score

38

—

LowBetter than 85% of packages

Maintenance34

Infrequent updates — may be unmaintained

Popularity26

Limited adoption so far

Community14

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 ~69 days

Recently: every ~16 days

Total

14

Last Release

626d ago

Major Versions

v0.1.8 → v1.0.02024-06-26

v1.0.0 → 2.0.x-dev2024-08-29

PHP version history (2 changes)v0.1.0PHP &gt;=7.4

v1.0.0PHP &gt;=8.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/ec6b7fbb4d231b5c2c76348cf3a13ec5e82c64a1826142f6ec0db1cf15db2873?d=identicon)[proggeler](/maintainers/proggeler)

![](https://www.gravatar.com/avatar/ea1df8d4eb476756f31e2c698e8b2c161c8be1b8482091f930abbddfd8d2fc52?d=identicon)[lingonl](/maintainers/lingonl)

---

Top Contributors

[![proggeler](https://avatars.githubusercontent.com/u/18281353?v=4)](https://github.com/proggeler "proggeler (27 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/dmt-software-http-client-middleware/health.svg)

```
[![Health](https://phpackages.com/badges/dmt-software-http-client-middleware/health.svg)](https://phpackages.com/packages/dmt-software-http-client-middleware)
```

###  Alternatives

[cakephp/cakephp

The CakePHP framework

8.8k18.5M1.6k](/packages/cakephp-cakephp)[laudis/neo4j-php-client

Neo4j-PHP-Client is the most advanced PHP Client for Neo4j

184616.9k31](/packages/laudis-neo4j-php-client)[flow-php/flow

PHP ETL - Extract Transform Load - Data processing framework

81733.7k](/packages/flow-php-flow)[neos/flow

Flow Application Framework

862.0M451](/packages/neos-flow)[neos/flow-development-collection

Flow packages in a joined repository for pull requests.

144179.3k3](/packages/neos-flow-development-collection)[windwalker/framework

The next generation PHP framework.

25639.1k1](/packages/windwalker-framework)

PHPackages © 2026

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