PHPackages                             easy-http/mock-builder - 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. easy-http/mock-builder

ActiveLibrary

easy-http/mock-builder
======================

A fluid interface to build HTTP mocks with an expressive syntax

v1.3.0(9mo ago)239.3k↑34.1%MITPHPPHP ^7.4|^8.0CI passing

Since Mar 6Pushed 9mo ago1 watchersCompare

[ Source](https://github.com/easy-http/mock-builder)[ Packagist](https://packagist.org/packages/easy-http/mock-builder)[ RSS](/packages/easy-http-mock-builder/feed)WikiDiscussions 1.x Synced today

READMEChangelogDependencies (5)Versions (8)Used By (0)

[![](https://camo.githubusercontent.com/4d72bcee08ff9c2af10e9b42bcaacfce19ac3fe90f631f4964ceb3a996166f5d/68747470733a2f2f626c6f672e706c656574732e6f72672f696d672f61727469636c65732f656173792d687474702d6c6f676f2d3332302e706e67)](https://camo.githubusercontent.com/4d72bcee08ff9c2af10e9b42bcaacfce19ac3fe90f631f4964ceb3a996166f5d/68747470733a2f2f626c6f672e706c656574732e6f72672f696d672f61727469636c65732f656173792d687474702d6c6f676f2d3332302e706e67)

[![Build Status](https://github.com/easy-http/mock-builder/actions/workflows/tests.yml/badge.svg?branch=1.x)](https://github.com/easy-http/mock-builder/actions/workflows/tests.yml)[![Bugs](https://camo.githubusercontent.com/784831ddfa5ac8e94aac4ece070a6dcfba3d296eb5744443f984e595c6a15d69/68747470733a2f2f736f6e6172636c6f75642e696f2f6170692f70726f6a6563745f6261646765732f6d6561737572653f70726f6a6563743d656173792d687474705f6d6f636b2d6275696c646572266d65747269633d72656c696162696c6974795f726174696e67266272616e63683d312e78)](https://sonarcloud.io/component_measures?metric=reliability_rating&branch=1.x&id=easy-http_mock-builder)[![Bugs](https://camo.githubusercontent.com/b2bc49565ae2ebc4f6533b7c89036f8c42c4e46d550482b26dc5a62cde7127d6/68747470733a2f2f736f6e6172636c6f75642e696f2f6170692f70726f6a6563745f6261646765732f6d6561737572653f70726f6a6563743d656173792d687474705f6d6f636b2d6275696c646572266d65747269633d636f766572616765266272616e63683d312e78)](https://sonarcloud.io/component_measures?metric=coverage&branch=1.x&id=easy-http_mock-builder)

 [![PHP Versions Supported](https://camo.githubusercontent.com/cd0d962a7e92e259d4961cb01363de809b25ef00fe6babe97e8c12e58e44fecd/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d372e34253230746f253230382e342d3737376262332e7376673f6c6f676f3d706870266c6f676f436f6c6f723d7768697465266c6162656c436f6c6f723d353535353535)](#tada-php-support "PHP Versions Supported") [![Total Downloads](https://camo.githubusercontent.com/27bc7182150f03b293bcc9eeb05215af85c76211223fa62b6cfa08df3e2debaf/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f656173792d687474702f6d6f636b2d6275696c646572)](https://packagist.org/packages/easy-http/mock-builder)

 🚀 Mock HTTP services

Mock builder
============

[](#mock-builder)

A fluid interface to build HTTP mocks with an expressive syntax. You can use this library to build mocks for Guzzle, Symfony and other HTTP Clients.

[![Bugs](https://camo.githubusercontent.com/b388e6c9cd8375a0dfdd113b4da902043e494f792ff4995fd424eb22d7f20309/68747470733a2f2f736f6e6172636c6f75642e696f2f6170692f70726f6a6563745f6261646765732f6d6561737572653f70726f6a6563743d656173792d687474705f6d6f636b2d6275696c646572266d65747269633d73656375726974795f726174696e67266272616e63683d312e78)](https://sonarcloud.io/component_measures?metric=security_rating&branch=1.x&id=easy-http_mock-builder)[![Bugs](https://camo.githubusercontent.com/855b2e02ad9a1ed46b30f9221610f29d0959d055ae492a7c1f36cc26be81668f/68747470733a2f2f736f6e6172636c6f75642e696f2f6170692f70726f6a6563745f6261646765732f6d6561737572653f70726f6a6563743d656173792d687474705f6d6f636b2d6275696c646572266d65747269633d62756773266272616e63683d312e78)](https://sonarcloud.io/component_measures?metric=bugs&branch=1.x&id=easy-http_mock-builder)[![Bugs](https://camo.githubusercontent.com/88d25ed3e1894db2cd0ff9a96ef85ab311de53e032e9fde2be84ca04cbc1ce08/68747470733a2f2f736f6e6172636c6f75642e696f2f6170692f70726f6a6563745f6261646765732f6d6561737572653f70726f6a6563743d656173792d687474705f6d6f636b2d6275696c646572266d65747269633d636f64655f736d656c6c73266272616e63683d312e78)](https://sonarcloud.io/component_measures?metric=code_smells&branch=1.x&id=easy-http_mock-builder)

This library supports the following versions of Guzzle Http Client.

[![PHP Versions Supported](https://camo.githubusercontent.com/ff90e670c378a22cf9216b642b69728322063acbee83d2d66c5eeb7ee4fd97a0/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f67757a7a6c652d362e782d626c7565)](#tada-php-support "Guzzle Version Supported")[![PHP Versions Supported](https://camo.githubusercontent.com/08b9eff3412a14ec4aa55f3a9ba7f98bf80c0c5460a92f55846feef813e7b150/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f67757a7a6c652d372e782d626c7565)](#tada-php-support "Guzzle Version Supported")

🔧 Installation
==============

[](#wrench-installation)

Use following command to install this library:

```
composer require easy-http/mock-builder
```

💡 Usage
=======

[](#bulb-usage)

Creating a simple Mock for Guzzle
---------------------------------

[](#creating-a-simple-mock-for-guzzle)

```
use EasyHttp\MockBuilder\HttpMock;
use EasyHttp\MockBuilder\MockBuilder;
use GuzzleHttp\HandlerStack;
use GuzzleHttp\Client;

$builder = new MockBuilder();
$builder
    ->when()
        ->pathIs('/v1/products')
        ->methodIs('POST')
    ->then()
        ->body('bar');

$mock = new HttpMock($builder);

$client = new Client(['handler' => HandlerStack::create($mock)]);
$client
    ->post('/v1/products')
    ->getBody()
    ->getContents(); // bar
```

📚 Check out the [Documentation](https://easy-http.com/docs) to learn how to use this library.

###  Health Score

43

—

FairBetter than 91% of packages

Maintenance58

Moderate activity, may be stable

Popularity31

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity62

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

Recently: every ~285 days

Total

8

Last Release

279d ago

Major Versions

v0.3.0 → v1.0.02022-05-05

### Community

Maintainers

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

---

Top Contributors

[![darioriverat](https://avatars.githubusercontent.com/u/5879790?v=4)](https://github.com/darioriverat "darioriverat (163 commits)")

---

Tags

guzzlemockphphttp mockGuzzle MockHTTP Mock Builder

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/easy-http-mock-builder/health.svg)

```
[![Health](https://phpackages.com/badges/easy-http-mock-builder/health.svg)](https://phpackages.com/packages/easy-http-mock-builder)
```

###  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.0M98](/packages/kevinrob-guzzle-cache-middleware)

PHPackages © 2026

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