PHPackages                             tijmenwierenga/guzzle-mock-handler - 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. [Testing &amp; Quality](/categories/testing)
4. /
5. tijmenwierenga/guzzle-mock-handler

ActiveLibrary[Testing &amp; Quality](/categories/testing)

tijmenwierenga/guzzle-mock-handler
==================================

A better Guzzle mock handler

v0.0.3(5y ago)11.2k1MITPHPPHP ^7.4|^8.0CI failing

Since Feb 23Pushed 3y ago1 watchersCompare

[ Source](https://github.com/TijmenWierenga/guzzle-mock-handler)[ Packagist](https://packagist.org/packages/tijmenwierenga/guzzle-mock-handler)[ RSS](/packages/tijmenwierenga-guzzle-mock-handler/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependencies (7)Versions (4)Used By (0)

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

[](#better-guzzle-mock-handler)

[![Build status](https://github.com/tijmenwierenga/guzzle-mock-handler/workflows/PHP%20Composer/badge.svg)](https://github.com/tijmenwierenga/guzzle-mock-handler/workflows/PHP%20Composer/badge.svg)

[![Buy us a tree](https://camo.githubusercontent.com/15453546808b5ea47b48633f72f490420e2e41b885556eee95d7e88f4a754418/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f54726565776172652d2546302539462538432542332d6c69676874677265656e3f7374796c653d666f722d7468652d6261646765)](https://plant.treeware.earth/TijmenWierenga/guzzle-mock-handler)

While the Guzzle HTTP client ships with a basic mock handler it might not be powerful enough in certain situations. For example, when your requests don't arrive in an expected order. That's where this Mock Handler might come in handy.

You'll be able to set expectations for incoming requests. When an expectation is met a predefined response will be returned.

Requirements
------------

[](#requirements)

Minimum PHP version is 7.4.

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

[](#installation)

Usually you'll want to install this package as a development dependency:

```
composer install tijmenwierenga/guzzle-mock-handler --dev
```

If you want to install the package for production:

```
composer install tijmenwierenga/guzzle-mock-handler
```

Usage
-----

[](#usage)

### Instantiating the handler

[](#instantiating-the-handler)

The Mock Handler works in a similar way as the official Guzzle Mock Handler. Add it as the handler for the `HandlerStack` and all requests will passed to the handler.

```
