PHPackages                             hasnat/guzzle-mirror-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. hasnat/guzzle-mirror-middleware

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

hasnat/guzzle-mirror-middleware
===============================

This package allows you to mirror requests in guzzle.

v1.0.5(6y ago)17931Apache-2.0PHPPHP &gt;=7.0CI failing

Since Sep 22Pushed 6y ago1 watchersCompare

[ Source](https://github.com/hasnat/guzzle-mirror-middleware)[ Packagist](https://packagist.org/packages/hasnat/guzzle-mirror-middleware)[ Docs](https://github.com/hasnat/guzzle-mirror-middleware)[ RSS](/packages/hasnat-guzzle-mirror-middleware/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (6)Dependencies (4)Versions (7)Used By (0)

Guzzle Mirror Middleware
========================

[](#guzzle-mirror-middleware)

[![Latest Version](https://camo.githubusercontent.com/9af4a8cbe4f8f545ab6127209141ebf6952289f8365dd117f85316881c529f39/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f6861736e61742f67757a7a6c652d6d6972726f722d6d6964646c65776172652e7376673f7374796c653d666c61742d737175617265)](https://github.com/hasnat/guzzle-mirror-middleware/releases)[![Build Status](https://camo.githubusercontent.com/7d94ca1bcecf4fc3ededc7e3c8748c5ba70aad5c607e41e15aa281b19bffc8bc/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f6861736e61742f67757a7a6c652d6d6972726f722d6d6964646c65776172652f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/hasnat/guzzle-mirror-middleware)[![Total Downloads](https://camo.githubusercontent.com/4dd3781a1a5ed29843ccd34337543d8c581826dce0afceb6924652991bfd2620/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6861736e61742f67757a7a6c652d6d6972726f722d6d6964646c65776172652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/hasnat/guzzle-mirror-middleware)

This package provides middleware for [guzzle](https://github.com/guzzle/guzzle/) for mirroring request to multiple clients:

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

[](#installation)

To install, use composer:

```
composer require hasnat/guzzle-mirror-middleware

```

Usage
-----

[](#usage)

To use this middleware, you need to initialize it like:

Setup Mirror Clients:

```
$mirrorsMiddleware = new \GuzzleMirror\GuzzleMirrorMiddleware([
    'mirrors' => [
        [
            'client' => new \GuzzleHttp\Client(['base_uri' => 'http://mirror1.com/']),
            'ignore_mirror_failures'    => false, // default=false -- failures will be sent on ignored_failures_callback, on true MirrorFailedException is thrown
            'ignore_mirror_methods'     => ['GET'] // default=[] -- all the methods you'd like to ignore for this mirror
        ],
        [
            'client' => new \GuzzleHttp\Client(['base_uri' => 'http://mirror2.com/'])
        ],
        [
            'client' => new \GuzzleHttp\Client(['base_uri' => 'http://mirror3.com/'])
        ]
    ],
    'mirrors_concurrency'       => 4,  // default=4 -- send to 4 mirrors at a time
    'no_mirror_on_failure'      => true, // default=true -- if there's a failure in main request don't send to mirrors
    'mirror_responses'          => function(array $responses) {}, // default=null -- all mirror responses
    'ignored_failures_callback' => function(array $failures) {}, // default=null -- when ignoring failures no MirrorFailedException is thrown but you can get failures here
])
```

And inject it to Guzzle with something like:

```
$handlerStack = HandlerStack::create();
$handlerStack->push(new \GuzzleMirror\GuzzleMirrorMiddleware([
    'mirrors' => [
        ['client' => new \GuzzleHttp\Client(['base_uri' => 'http://mirror1.com/'])],
        ['client' => new \GuzzleHttp\Client(['base_uri' => 'http://mirror2.com/'])],
        ['client' => new \GuzzleHttp\Client(['base_uri' => 'http://mirror3.com/'])]
    ]
]));
$this->client = new GuzzleHttp\Client([
    'base_uri' => 'base_uri' => 'http://example.com/',
    'handler' => $handlerStack
]);
```

From now on every request sent with `$guzzleClient` will be replicated on mirrors.

Testing
-------

[](#testing)

`hasnat/guzzle-mirror-middleware` has a [PHPUnit](https://phpunit.de) test suite and a coding style compliance test suite using [PHP CS Fixer](http://cs.sensiolabs.org/).

To run the tests, run the following command from the project folder.

```
$ docker-compose run test
```

License
-------

[](#license)

MIT

###  Health Score

28

—

LowBetter than 52% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity16

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

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

Total

6

Last Release

2466d ago

PHP version history (2 changes)v1.0PHP &gt;=7.1

v1.0.3PHP &gt;=7.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/0691785937e1af9a2e3080381307d8fa368b97e08bf8aad2a8e45f04fe0b1351?d=identicon)[hasnat](/maintainers/hasnat)

---

Top Contributors

[![hasnat](https://avatars.githubusercontent.com/u/907125?v=4)](https://github.com/hasnat "hasnat (6 commits)")

---

Tags

middlewareGuzzleduplicatemultiplerequestsmirror

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/hasnat-guzzle-mirror-middleware/health.svg)

```
[![Health](https://phpackages.com/badges/hasnat-guzzle-mirror-middleware/health.svg)](https://phpackages.com/packages/hasnat-guzzle-mirror-middleware)
```

###  Alternatives

[aws/aws-sdk-php

AWS SDK for PHP - Use Amazon Web Services in your PHP project

6.2k532.1M2.5k](/packages/aws-aws-sdk-php)[kevinrob/guzzle-cache-middleware

A HTTP/1.1 Cache for Guzzle 6. It's a simple Middleware to be added in the HandlerStack. (RFC 7234)

43518.2M126](/packages/kevinrob-guzzle-cache-middleware)[caseyamcl/guzzle_retry_middleware

Guzzle v6+ retry middleware that handles 429/503 status codes and connection timeouts

21911.7M71](/packages/caseyamcl-guzzle-retry-middleware)[rtheunissen/guzzle-log-middleware

Guzzle middleware to log requests and responses

822.3M17](/packages/rtheunissen-guzzle-log-middleware)[eljam/guzzle-jwt-middleware

A jwt authentication middleware for guzzle 6

28750.0k3](/packages/eljam-guzzle-jwt-middleware)[rtheunissen/guzzle-rate-limiter

Guzzle 6 middleware used to delay requests dynamically

52179.4k1](/packages/rtheunissen-guzzle-rate-limiter)

PHPackages © 2026

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