PHPackages                             emanueleminotto/guzzle-snapshot - 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. emanueleminotto/guzzle-snapshot

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

emanueleminotto/guzzle-snapshot
===============================

Guzzle Snapshots Middleware

1.1.0(5y ago)210.2k1MITPHPPHP ~7.1

Since Mar 3Pushed 5y ago1 watchersCompare

[ Source](https://github.com/EmanueleMinotto/guzzle-snapshot)[ Packagist](https://packagist.org/packages/emanueleminotto/guzzle-snapshot)[ RSS](/packages/emanueleminotto-guzzle-snapshot/feed)WikiDiscussions master Synced 1w ago

READMEChangelog (3)Dependencies (5)Versions (4)Used By (0)

Guzzle Snapshots Middleware
===========================

[](#guzzle-snapshots-middleware)

[![Latest Version on Packagist](https://camo.githubusercontent.com/835e49166e079289d2c69628c1c12bfe4e4a4f8a7a78d975ff2f4fc2bb6bf37c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f656d616e75656c656d696e6f74746f2f67757a7a6c652d736e617073686f742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/emanueleminotto/guzzle-snapshot)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Build Status](https://camo.githubusercontent.com/8d80f73ec6d0d0b85465d96429c9bb0ca421193d270edef4b94eed5b2bcbaf11/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f456d616e75656c654d696e6f74746f2f67757a7a6c652d736e617073686f742f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/EmanueleMinotto/guzzle-snapshot)[![Coverage Status](https://camo.githubusercontent.com/e40de57b46bc463946f9411568dc2944cb53ffb5efa11a019b15d1748cab05a2/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f456d616e75656c654d696e6f74746f2f67757a7a6c652d736e617073686f742e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/EmanueleMinotto/guzzle-snapshot/code-structure)[![Quality Score](https://camo.githubusercontent.com/d025c51206bb89d75533f24f23a36d25535ac99f634597d4578360ebc1bd32e1/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f456d616e75656c654d696e6f74746f2f67757a7a6c652d736e617073686f742e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/EmanueleMinotto/guzzle-snapshot)[![Total Downloads](https://camo.githubusercontent.com/93c82fa7205b11fd9f55ffcc4f7563dbbb66b0fd8b9f35bd15cb04c0a8f99c9f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f656d616e75656c656d696e6f74746f2f67757a7a6c652d736e617073686f742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/emanueleminotto/guzzle-snapshot)

[Guzzle](https://github.com/guzzle/guzzle) 6 &amp; 7 middleware to store responses and requests and replay them in tests.

Structure
---------

[](#structure)

If any of the following are applicable to your project, then the directory structure should follow industry best practices by being named the following.

```
bin/
config/
src/
tests/
vendor/

```

Install
-------

[](#install)

Via Composer

```
$ composer require emanueleminotto/guzzle-snapshot
```

Usage
-----

[](#usage)

```
use EmanueleMinotto\GuzzleSnapshot\Strategy\ReadableFileStrategy;
use GuzzleHttp\Client;
use GuzzleHttp\HandlerStack;
// use Doctrine\Common\Cache\ArrayCache;
// use EmanueleMinotto\GuzzleSnapshot\Strategy\DoctrineCacheStrategy;

// $strategy = new DoctrineCacheStrategy(new ArrayCache());
$strategy = new ReadableFileStrategy(__DIR__.'/__snapshots__');
$middleware = new SnapshotMiddleware($strategy);
// $middleware->setRequestStorage(true); // this will save requests too

$stack = HandlerStack::create();
$stack->push($middleware);

$client = new Client([
    'handler' => $this->stack,
]);

// if the response file was already stored in
// the directory __snapshots___, this request wont
// be sent to the remote endpoint
$client->get('http://www.example.com/');

// this request wont be sent in any case
$client->get('http://www.example.com/');
```

Testing
-------

[](#testing)

```
$ composer test
```

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) and [CODE\_OF\_CONDUCT](CODE_OF_CONDUCT.md) for details.

Security
--------

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [Emanuele Minotto](https://github.com/EmanueleMinotto)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity22

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity57

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 54.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

Every ~317 days

Total

3

Last Release

1999d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/30b6fbd038f22a54716027eb7ce30c6cafd8e59c138ae58b3c2516c34ccfef7f?d=identicon)[EmanueleMinotto](/maintainers/EmanueleMinotto)

---

Top Contributors

[![EmanueleMinotto](https://avatars.githubusercontent.com/u/417201?v=4)](https://github.com/EmanueleMinotto "EmanueleMinotto (6 commits)")[![Firtzberg](https://avatars.githubusercontent.com/u/8490119?v=4)](https://github.com/Firtzberg "Firtzberg (4 commits)")[![crissi](https://avatars.githubusercontent.com/u/3076578?v=4)](https://github.com/crissi "crissi (1 commits)")

---

Tags

middlewaresnapshotGuzzle

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/emanueleminotto-guzzle-snapshot/health.svg)

```
[![Health](https://phpackages.com/badges/emanueleminotto-guzzle-snapshot/health.svg)](https://phpackages.com/packages/emanueleminotto-guzzle-snapshot)
```

###  Alternatives

[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)

43117.4M104](/packages/kevinrob-guzzle-cache-middleware)[caseyamcl/guzzle_retry_middleware

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

21610.7M64](/packages/caseyamcl-guzzle-retry-middleware)[rtheunissen/guzzle-log-middleware

Guzzle middleware to log requests and responses

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

A jwt authentication middleware for guzzle 6

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

Guzzle 6 middleware used to delay requests dynamically

52177.2k1](/packages/rtheunissen-guzzle-rate-limiter)[brightfish/caching-guzzle

Cache HTTP responses through Guzzle middleware

1031.5k](/packages/brightfish-caching-guzzle)

PHPackages © 2026

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