php-http/vcr-plugin
A PHP-HTTP plugin that records real HTTP interactions and replays them in tests, similar to Ruby's VCR. Drop it into any HTTPlug-compatible client to capture responses once, then run fast, deterministic, offline test suites without hitting external APIs.
Architecture fit. php-http/vcr-plugin is a test-only HTTP middleware: it wraps an HTTP client, records request/response pairs to "cassette" files on first run, and replays them on subsequent runs. It fits the php-http/HTTPlug plugin model and is a dev dependency, not a runtime one — so it does not enter the production request path or affect deployed artifacts. For teams already using plugin-capable clients, it is a clean, composable addition; for teams on a plain PSR-18 client with no plugin layer, an adapter is needed and fit is weaker.
Integration feasibility. Low effort to trial: one Composer require-dev, wrap the client in the test container/bootstrap, point it at a cassette directory. The record/replay concept is well understood (VCR in Ruby, Betamax in Java), so the team's mental model transfers. Real effort sits in configuration correctness — matching rules, record modes, and scrubbing — not in wiring.
Technical risk. The dominant risk is project maturity, not code quality. At 21 stars with an unresolvable repository reference, we cannot inspect commit history, CI status, issue responsiveness, or release cadence from this data. That means no observable bus factor, no visible security policy, and no confidence signal beyond "released recently under MIT." Secondary risks:
| Risk | Severity | Notes |
|---|---|---|
| Upstream abandonment / single maintainer | High | Small ecosystem footprint; fork-and-own is the fallback |
| Cassette format drift across versions | Medium | Pin version; treat cassettes as generated artifacts |
| Secret leakage in committed cassettes | High | Requires header/body scrubbing before first commit |
| Compatibility with our specific client | Medium | Verify plugin interface vs. PSR-18 adapter support |
| False confidence from stale recordings | Medium | Tests pass against old API shapes; needs refresh policy |
Key questions.
Stack fit. Strong fit for a PHP 8.x codebase running PHPUnit or Pest against an HTTPlug-based client. Weak-to-moderate fit if the application has already consolidated on a client outside that plugin ecosystem — in that case compare against native alternatives (e.g., client-specific mock handlers or a lighter cassette wrapper) before committing.
Migration path. Introduce as a require-dev dependency and adopt incrementally: wrap the client only in test bootstrap, leave application code untouched, and let existing unit tests continue with their current mocking. Convert integration tests suite-by-suite. The package is additive, so rollback is deleting the dependency and the cassette directory — no migration debt.
Compatibility. Confirm three things before rollout: (a) our client version is supported by the plugin, (b) PSR-7/PSR-17 message factories align, and (c) cassette format is stable within a pinned minor version. Pin exact versions in composer.json and treat upgrades as reviewed changes, not routine composer update drift.
Sequencing.
.gitignore vs. commit decision, replay-only enforcement in CI.Maintenance. Small surface area — a dev dependency and a cassette directory. The real maintenance load is cassette hygiene: recordings age as upstream APIs evolve, so we need an owner and a periodic refresh cadence (e.g., re-record on API version changes). Pinning versions keeps upgrade work deliberate. If upstream stalls, forking is feasible given the narrow scope, but budget for it as a contingency rather than assume it away.
Support. No vendor, no SLA. Support is internal: whoever owns the test infrastructure owns this. The low star count means community answers will be thin, so document our configuration and conventions internally — that documentation becomes the de facto support artifact.
Scaling. Benefits scale with the number of integration tests that hit external services: fewer network calls, faster and more deterministic CI. Costs scale too — cassette count and size grow, inflating repository size and checkout time. Mitigate with per-suite cassette directories, size limits, pruning of unused recordings, and a policy that cassettes are reviewed like code.
Failure modes.
Ramp-up. Low for engineers who know the VCR pattern — roughly half a day to first productive use, one to two days to learn matching rules and scrubbing. Engineers unfamiliar with record/replay need a short primer on cassette governance and the replay-only CI rule, since the most common failure is treating recordings as opaque magic rather than reviewed fixtures.
TPM recommendation. Adopt conditionally, as a dev-only dependency, gated on three checks: native support for our chosen client, working scrubbing, and a pinned version we can own. The technical risk is contained by its test-only scope and easy rollback; the maturity risk is real but manageable through pinning, internal documentation, and a fork contingency. Do not adopt if the spike shows adapter friction or if scrubbing cannot be enforced — in that case the secret-leakage risk alone disqualifies it.
How can I help you explore Laravel packages today?