PHPackages                             kagency/http-replay - 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. kagency/http-replay

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

kagency/http-replay
===================

Library to replay and compare HTTP requets and responses

0.3(11y ago)1258MITPHP

Since Jun 19Pushed 11y ago2 watchersCompare

[ Source](https://github.com/Kagency/http-replay)[ Packagist](https://packagist.org/packages/kagency/http-replay)[ RSS](/packages/kagency-http-replay/feed)WikiDiscussions master Synced today

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

HTTP Replay Test Helper
=======================

[](#http-replay-test-helper)

[![Travis Build Status](https://camo.githubusercontent.com/197b4e1779f0403058f64f5b7e99022734d992fbb29fa0909b45c56f87f0ef6b/68747470733a2f2f7472617669732d63692e6f72672f4b6167656e63792f687474702d7265706c61792e737667 "Travis Build Status")](https://travis-ci.org/Kagency/http-replay)

This is a libaray to replay requests and responses in tests. It allows to filter the responses to remove values, one does not want to assert on.

Supported Tools
---------------

[](#supported-tools)

Supported recordings (Reader):

- [MitmDump](http://mitmproxy.org/doc/mitmdump.html)

Supported frameworks (MessageHandler):

- [Symfony2](http://symfony.com/)

Workflow
--------

[](#workflow)

The workflow for using this test helper could be:

First record some HTTP interaction using MitmDump, executing something like this:

```
mitmdump -P http://my-website:80/ -p 8080 --anticache -z -w recordFile.tns

```

The stored file can then be replayed against your application – in my case a Symfony2 stack – by implementing an integration test like this:

```
$messageHandler = new MessageHandler\Symfony2();
$filter = new ResponseFilter\Dispatcher(array(
    new ResponseFilter\Json(),
    new ResponseFilter\Headers(array(
        'date',
        'etag',
    )),
));

$reader = new Reader\MitmDump($messageHandler);
$interactions = $reader->readInteractions('recordFile.tns');

foreach ($interactions as $interaction) {
    $actualResponse = $app->runRequest($interaction->request);

    $this->assertEquals(
        $filter->filterResponse($messageHandler->simplifyResponse($interaction->request, $interaction->response)),
        $filter->filterResponse($messageHandler->simplifyResponse($interaction->request, $actualResponse))
    );
}
```

This example only implements a very basic set of response filters. You can implement conditional response filters, which only act for certain request URLs and filter, for example, certain JSON properties out of the response.

This example assumes $app is some Symfony2 app, where the method runRequest() recieves a Request object and returns a Response object.

Response Filters
----------------

[](#response-filters)

A list of currently implemented response filters

### Dispatcher

[](#dispatcher)

Takes an array of response filters to apply to the responses. You usually want to use this one to be able to easily apply a set of filters.

### Json

[](#json)

Tries to parse JSON to make it easier to compare in tests. Also makes other response filters possible, like the JsonFilter filter.

Takes no arguments.

### JsonFilter

[](#jsonfilter)

Filters out a defined set of properties from a JSON response. Especially sensible, if your JSON response contains fields like dates or revisions.

Receives a list of properties to remove as a constructor argument.

### Headers

[](#headers)

Implements a blacklist for HTTP headers. Removes those headers from the response. This is especially useful to remove Date and Etag headers, for example.

Receives a list of headers to remove as a constructor argument.

### MultipartMixed

[](#multipartmixed)

Replaces the random boundary string in multipart/mixed responses, to make it possible to comapre them.

Takes no arguments.

### ConditionalPathRegexp

[](#conditionalpathregexp)

Takes to arguments:

- Regular expression to match the requested path
- Aggregate filter

Only applies the aggregate filter, if the regular expression matches the requested path.

Verify the Build
----------------

[](#verify-the-build)

You can verify the build by running ant:

```
ant

```

This installs all required tools using composer and then runs the tests and static source code verification. You might also run all the tools manually, like:

```
vendor/bin/phpunit

```

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity56

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

Total

4

Last Release

4120d ago

### Community

Maintainers

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

---

Top Contributors

[![kore](https://avatars.githubusercontent.com/u/154398?v=4)](https://github.com/kore "kore (37 commits)")

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/kagency-http-replay/health.svg)

```
[![Health](https://phpackages.com/badges/kagency-http-replay/health.svg)](https://phpackages.com/packages/kagency-http-replay)
```

###  Alternatives

[nelmio/api-doc-bundle

Generates documentation for your REST API from attributes

2.3k63.6M232](/packages/nelmio-api-doc-bundle)[api-platform/core

Build a fully-featured hypermedia or GraphQL API in minutes!

2.6k48.1M236](/packages/api-platform-core)[friendsofsymfony/http-cache-bundle

Set path based HTTP cache headers and send invalidation requests to your HTTP cache

43813.2M47](/packages/friendsofsymfony-http-cache-bundle)[illuminate/http

The Illuminate Http package.

11936.0M5.0k](/packages/illuminate-http)[api-platform/state

API Platform state interfaces

223.4M57](/packages/api-platform-state)[api-platform/validator

API Platform validator component

223.2M10](/packages/api-platform-validator)

PHPackages © 2026

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