PHPackages                             verdet/guzzle-mock - 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. verdet/guzzle-mock

ActiveGuzzle-extension[HTTP &amp; Networking](/categories/http)

verdet/guzzle-mock
==================

Guzzle Mock Handler

1.0.0(3y ago)062[1 PRs](https://github.com/verdet23/guzzle-mock/pulls)MITPHPPHP ^8.0

Since Aug 15Pushed 2y ago1 watchersCompare

[ Source](https://github.com/verdet23/guzzle-mock)[ Packagist](https://packagist.org/packages/verdet/guzzle-mock)[ RSS](/packages/verdet-guzzle-mock/feed)WikiDiscussions master Synced 4w ago

READMEChangelog (1)Dependencies (2)Versions (3)Used By (0)

Guzzle Mock Handler
===================

[](#guzzle-mock-handler)

[![Packagist Version](https://camo.githubusercontent.com/9e5d2a50f221ab73ed85698ee6d660bab21a195a8722a9b335a4e5a15eddda77/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7665726465742f67757a7a6c652d6d6f636b)](https://packagist.org/packages/verdet/guzzle-mock)[![CI](https://github.com/verdet23/guzzle-mock/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/verdet23/guzzle-mock/actions/workflows/ci.yml)[![Coverage Status](https://camo.githubusercontent.com/806a108cb09edcdc46c5f0793ec7cf02a72657534f9787553591dc6edc03faf5/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f76657264657432332f67757a7a6c652d6d6f636b2f62616467652e737667)](https://coveralls.io/github/verdet23/guzzle-mock)[![PHPStan](https://camo.githubusercontent.com/ff3c7f8c8667ce643f47e74532748f673482a5f95d7d4269f925f2eebbe5117e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048505374616e2d6c6576656c253230382d627269676874677265656e)](https://raw.githubusercontent.com/verdet23/guzzle-mock/master/phpstan.neon)[![Coding Style](https://camo.githubusercontent.com/faa746ca89eb980ded011b1bf6d6d9fdc1494c0f6323d9e7e0586d90901ce2d1/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f436f64696e672532305374796c652d5053522d2d31322d79656c6c6f77677265656e)](https://www.php-fig.org/psr/psr-12/)[![License](https://camo.githubusercontent.com/632f0132887b98079b60f171a98d01e9c2853388b9d39508c813b98fce508d2f/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f76657264657432332f67757a7a6c652d6d6f636b3f636f6c6f723d626c7565)](https://raw.githubusercontent.com/verdet23/guzzle-mock/master/LICENSE)[![Packagist PHP Version Support](https://camo.githubusercontent.com/e82f1a933b27f79339917176e0fc4e01ff067167336092ac55e0d80b1037d63d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f7665726465742f67757a7a6c652d6d6f636b)](https://camo.githubusercontent.com/e82f1a933b27f79339917176e0fc4e01ff067167336092ac55e0d80b1037d63d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f7665726465742f67757a7a6c652d6d6f636b)

Description
-----------

[](#description)

Inspired by [guzzle/guzzle](https://github.com/guzzle/guzzle) MockHandler and [alekseytupichenkov/GuzzleStub](https://github.com/alekseytupichenkov/GuzzleStub) library.

Mock Handler functional same as default `GuzzleHttp\Handler\MockHandler` except filling queue. Argument `$queue` expected to be array of Request and Response objects. When you pass Request to MockHanlder it will try to find suitable Request in queue and return paired Response.

Prerequisite
------------

[](#prerequisite)

php &gt;= 8.0
guzzlehttp/guzzle &gt;= 7.0

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

[](#installation)

Use the package manager [composer](https://getcomposer.org/) to install.

```
composer require --dev verdet/guzzle-mock
```

Basic usage
-----------

[](#basic-usage)

```
// Create a mock and queue three pairs of request and responses.
$mock = new MockHandler([
            [
                new Request('GET', 'https://example.com'),
                new Response(200, ['X-Foo' => 'Bar'], 'Hello, World')
            ],
            [
                new Request('GET', 'https://example.com/latest'),
                new Response(202, ['Content-Length' => '0'])],
            [
                new Request('POST', 'https://example.com/foo'),
                new RequestException('Error Communicating with Server', new Request('POST', 'https://example.com/foo'))
            ]
        ]);
```

Rest of usage same as

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity53

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

Unknown

Total

1

Last Release

1363d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/5bbe5b4d7eb080554f1862a4d067fdf8e5b01d8c81db5a4ad98c0c72bfe48846?d=identicon)[verdet23](/maintainers/verdet23)

---

Top Contributors

[![verdet23](https://avatars.githubusercontent.com/u/692270?v=4)](https://github.com/verdet23 "verdet23 (21 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/verdet-guzzle-mock/health.svg)

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

###  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)[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)[ory/hydra-client-php

Documentation for all of Ory Hydra's APIs.

1710.8k](/packages/ory-hydra-client-php)

PHPackages © 2026

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