nicolasguilloux/wiremock-bundle
Symfony bundle that integrates WireMock into your test suite, letting you start stub HTTP services, define request/response mappings, and verify outgoing calls so functional tests run against realistic APIs without hitting external systems.
nicolasguilloux/wiremock-bundle is a Symfony bundle (Bundle subclass, config/packages/*.yaml, container tags), not a Laravel package. There is no extra.laravel.providers, no ServiceProvider, no facade. composer require it into a Laravel app and nothing will be wired; package discovery will ignore it. Treat this bundle as a reference implementation for the pattern, not as a drop-in dependency.docker run -p 8080:8080 wiremock/wiremock, or the wiremock-standalone.jar) and point your HTTP client's base_uri at it via config/services.php + env('WIREMOCK_URL', 'http://localhost:8080'). Read the bundle's YAML stub examples for the mappings/ layout shape, because that schema is WireMock's, not the bundle's.__files/ + mappings/, seed the WireMock container in setUp(), and assert your job or controller produced the right domain effect. That single seam is your rollback boundary if you ever decide to go back to Http::fake().Http::fake() first, WireMock second. Laravel's built-in fake covers the majority of controller/job tests with zero infrastructure. Reach for WireMock only when: you need real TCP/socket behavior, you're testing a Guzzle client used outside the Http facade, you want contract-level verification against a captured mapping, or a third-party SDK constructs its own transport.setUp() boots WireMock (or resets stubs via POST /__admin/reset), tearDown() stops it or restores. Put the base URL in a test-only env var and bind it in phpunit.xml, not in production config.tests/Fixtures/wiremock/{mappings,__files}. Keep them as YAML files checked into the repo — they double as living documentation of the external contract. Mount that directory into the WireMock container. Never generate them at runtime unless you need dynamic matches./__admin/requests. The bundle advertises request assertions; in a Laravel test you replicate this with a Guzzle call to GET /__admin/requests in tearDown or a helper, asserting method/path/body on the outbound call. This is the payoff WireMock gives you over Http::fake() — verifying what the app sent, not just faking what it receives.services.partner_a.base_uri, services.partner_b.base_uri) pointing at different ports. This keeps stubs isolated per integration.RepositoryServiceProvider that reads base_uri from config. That’s the one place that flips between real, WireMock, and Http::fake() — everything else in the app stays unaware.services:, GitLab services:, or docker-compose for local). Gate the WireMock-backed tests behind a @group integration so unit suites stay fast and don’t need Docker.php artisan vendor:publish, no config merge. Fighting this wastes time; the concepts transfer, the wiring does not./__admin/mappings payload shape, match operators). Pin the WireMock image tag explicitly and treat upgrades as a deliberate step.--parallel) or a local dev server will collide. Run WireMock with dynamic ports (--port 0 + read the assigned port) or allocate per-worker ports from an env var. The bundle’s "multiple instances" feature has the same failure mode.POST /__admin/reset (or DELETE /__admin/mappings + DELETE /__admin/requests) in tearDown, one test’s stub silently answers the next test’s call. This is the single most common source of “flaky” WireMock suites.Http::fake() and WireMock don’t compose. If any code path uses the Http facade, Http::fake() will intercept before the socket is opened and WireMock never sees the call. Mixing them yields confusing assertions (“request not received”) — pick one strategy per test class.env() at runtime. If you wire WIREMOCK_URL through anything other than config/*.php, config:cache in CI returns null. Keep the base URL in config files, not mid-process env() calls.curl http://localhost:8080/__admin/mappings shows what stubs are registered; curl http://localhost:8080/__admin/requests shows what actually arrived. When a test fails, check these before touching PHP — most failures are a stub that didn’t match (path typo, missing Content-Type, wrong HTTP method) rather than application logic.tests/Support/WireMock trait → stub fixture files → per-service config → (last resort) fork the Symfony bundle or write your own thin wrapper around the standalone server. There is no sensible path where patching vendor/nicolasguilloux/wiremock-bundle is the right answer.How can I help you explore Laravel packages today?