Description
PHP-VCR is a port of the Ruby VCR library to PHP. It records the HTTP interactions made by your test suite and replays them on later runs, so tests are fast, repeatable and do not depend on a live network. You turn it on in your bootstrap file, and it intercepts requests made through PHP stream wrappers, curl and SoapClient. Recorded requests and responses are stored as cassettes on disk. You insert a cassette for each test, so the same request can receive different responses in different tests. Requests you have not explicitly allowed are blocked by the record mode, and forgetting to insert a cassette throws an error instead of reaching the network. Four record modes are available: new_episodes, which is the default, once, none and all. Request matching can use the HTTP method, URI, host, path, body and headers, and you can write a custom matcher.…
Highlights
- Records and replays HTTP requests in tests
- Supports stream wrappers, curl and SOAP
- Configurable request matching
- Cassettes stored as YAML or JSON
- Four record modes
- Installs with Composer
Ratings & Reviews
No ratings yet
Be the first to rate PHP VCR.
People also visit
DevTools
Local-first API workflows that go from HAR file to GitHub Actions in 60 seconds
PHP VCR FAQ
What is PHP-VCR?
A PHP port of the Ruby VCR library that records HTTP interactions during tests and replays them on later runs.
Why use it?
Replayed tests are faster and more deterministic, and they do not need a live network connection.
Which HTTP libraries does it support?
PHP stream wrappers, the curl extension and SoapClient. All three hooks are enabled by default when you call VCR::turnOn().
What do I need?
PHP 8 and the curl extension, plus a few Composer packages that Composer installs for you.
What happens if I forget a cassette?
VCR throws immediately instead of silently calling the network.
What are the best PHP VCR alternatives?
Popular alternatives to PHP VCR include test-proxy-recorder, Pollyjs and MockServer. See all PHP VCR alternatives




