Select Library Hooks
One-liner: if you know which HTTP mechanism your code uses, enable only that hook — faster test runs, less to reason about.
On this page: Enable a subset · Why this matters
Enable a subset
\VCR\VCR::configure()->enableLibraryHooks(['curl']);
\VCR\VCR::turnOn();
Available names: stream_wrapper, curl, soap (see Library Hooks reference
for what each one intercepts). All three are enabled by default — this call restricts interception to just
the ones listed.
Why this matters
- Speed: the
curl/soaphooks scan every file loaded viainclude/requirefor rewritable calls. Disabling a hook you don't need (or narrowing the whitelist/blacklist) cuts down what gets scanned. - Scoping: if your codebase only ever talks HTTP through
ext-curl, there's no reason to also interceptSoapClient— one fewer mechanism to think about when debugging why a request wasn't recorded.
⚠️ Warning: whichever hooks you enable, remember the require/include constraint —
curlandsoaponly rewrite code loaded viainclude/requireafterturnOn(), never the top-level entry script. This was verified directly: acurl_exec()call written straight into the invoked script silently bypasses interception (real request goes through, nothing is recorded) — moving the same call into arequired file fixes it.stream_wrapperhas no such restriction.
← Custom request matcher · Next: Record SOAP requests →