Download the PHP package mtk3d/laravel-http-vcr without Composer

On this page you can find all versions of the php package mtk3d/laravel-http-vcr. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-http-vcr

laravel-http-vcr — record and replay HTTP in Laravel tests

Every Http:: call in a test with #[UseCassette] is recorded once and replayed on every run after that, with nothing to wire up.

Tests PHP 8.2+ Laravel 12–13

This is the Laravel bridge for mtk3d/http-vcr. The recording and replaying lives there; this package is the auto-wiring that puts it behind Laravel's Http facade.

No Http::fake(), no fixture to write by hand, no client to construct. The first run makes the real request and writes tests/Cassettes/shopify/get-product.yaml; every run after replays it — no network, no API key, no flakiness.

Installation

The service provider registers itself. One line in phpunit.xml is still needed, because PHPUnit has no auto-discovery for extensions:

That is the whole setup. Without it #[UseCassette] does nothing and every call reaches the real API — so the package checks for it while booting in the testing environment and says so once per run rather than letting it pass unnoticed.

Requires Laravel 12 or newer and PHP 8.2+ (Laravel 13 needs PHP 8.3).

What it does

A test with no #[UseCassette] behaves exactly as if this package were not installed — including Http::fake(), which is untouched.

Configuration

There is nothing Laravel-specific to configure, and no config file to publish. http-vcr reads an optional http-vcr.php in the project root, and its defaults already resolve to base_path('tests/Cassettes') and base_path('tests') in a Laravel application:

The root of the project rather than config/: the file returns a Config object carrying closures, and php artisan config:cache serialises every file in config/ with var_export() — a closure there turns a cached config into a fatal. Every option is in the configuration reference.

Assertions on a replayed call

Http::assertSent() works, with one line:

Http::record() is Laravel's own switch for the recorder behind those assertions. It is normally turned on as a side effect of Http::fake(), which a cassette replaces — so with cassettes it is asked for directly. The replayed call is reported to that recorder on purpose: assertSent() asks what the application did, and a replayed call is something the application did.

Http::preventStrayRequests()

A cassette does not fight it, and it does not have to be turned off:

Laravel enforces the guard in its stub handler, which is pushed onto the stack after global middleware and therefore sits inside this package's — so a replayed call is answered above it and never reaches it.

The run that records is a different matter. It goes down the whole stack, so it does reach the guard, and with no stub registered Laravel refuses it before it can reach the API. That is the guard working as intended, but it means the first run of a new cassette needs Http::allowStrayRequests() — narrow it to the host you are recording, and the guard keeps covering everything else:

The cassette format

YAML wherever symfony/yaml is installed, JSON otherwise — a Laravel application usually has it, so cassettes are usually YAML. To pin one either way, name the serializer in http-vcr.php; php artisan vcr:migrate rewrites existing recordings into the other format.

Everything else

Record modes, matchers, redaction, strict mode, staleAfter, cassette scoping, the CLI and the cassette format are the core library's, and they behave here exactly as they do anywhere else:

mtk3d.github.io/http-vcr

Not using this package

Http:: goes through Guzzle, so the middleware bridge works without any of this — at the cost of wiring the handler yourself in each test or in a testing-only service provider. The recipe is on the Laravel page of the book.

Development

CI runs PHPUnit across PHP 8.2–8.4 and Laravel 12–13, plus a leg on the lowest versions every constraint allows; PHPStan and Pint run once each, since neither answer depends on the framework release.

License

MIT — see LICENSE.


All versions of laravel-http-vcr with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
mtk3d/http-vcr Version ^0.1.1
guzzlehttp/guzzle Version ^7.0 || ^8.0
illuminate/console Version ^12.0 || ^13.0
illuminate/http Version ^12.0 || ^13.0
illuminate/support Version ^12.0 || ^13.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package mtk3d/laravel-http-vcr contains the following files

Loading the files please wait ...