PHPackages                             dshafik/guzzlehttp-vcr - 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. dshafik/guzzlehttp-vcr

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

dshafik/guzzlehttp-vcr
======================

6252.0k—3.5%4[1 PRs](https://github.com/dshafik/guzzlehttp-vcr/pulls)2PHP

Since Apr 4Pushed 7y ago2 watchersCompare

[ Source](https://github.com/dshafik/guzzlehttp-vcr)[ Packagist](https://packagist.org/packages/dshafik/guzzlehttp-vcr)[ RSS](/packages/dshafik-guzzlehttp-vcr/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (2)Used By (2)

[![License](https://camo.githubusercontent.com/850eae1099d2b05f53383473d7cd51f9bc1ab09b7d0d9e5122f1dd930efdcc6d/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f6d6173686170652f6170697374617475732e737667)](https://github.com/dshafik/guzzlehttp-vcr)[![Travis CI Status](https://camo.githubusercontent.com/20d9f4996db8238a610ebc8b9cc765aaf1f8511d0e66bb23e250a56904f912da/68747470733a2f2f7472617669732d63692e6f72672f6473686166696b2f67757a7a6c65687474702d7663722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/dshafik/guzzlehttp-vcr) [![Scrutinizer Code Quality](https://camo.githubusercontent.com/b42edeb1e1122199ff8dca22dc1ae18c01784e80391656e28e882770aabca222/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6473686166696b2f67757a7a6c65687474702d7663722f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/dshafik/guzzlehttp-vcr/?branch=master)

Guzzle VCR
==========

[](#guzzle-vcr)

Based on the idea of [PHP•VCR](http://php-vcr.github.io), this Guzzle Middleware will record responses and replay them in response to subsequent requests.

This middleware is simplistic in that it will simply replay the responses in order in response to *any* requests. This is handy for testing clients that have time-based authentication and need to generate dynamic requests but still want predictable responses to test response handling.

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

[](#installation)

To add to your project, use `composer`:

```
$ composer require dshafik/guzzlehttp-vcr

```

Usage
-----

[](#usage)

It's use is *similar* to Guzzles `\GuzzleHttp\Handler\MockHandler`, and in fact uses the `MockHandler` to replay the recorded requests. Calling the `Dshafik\GuzzleHttp\VcrHandler::turnOn()` method will return either an instance of the standard `GuzzleHttp\HandlerStack` with either the `VcrHandler` or `MockHandler` (with the requests loaded) added as middleware.

You then pass the handler in as the `GuzzleHttp\Client` handler option, either in the constructor, or with the individual request.

The recording is halted on script termination, or the next time `VcrHandler::turnOn()` is called *for that recording*.

```
