Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Wiremock Bundle Laravel Package

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.

View on GitHub
Deep Wiki
Context7

Getting Started

  • Read the Symfony-bundle warning first. 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.
  • Do not try to install the bundle. The package is archived (last release 2024-07-24, 1 star). A Laravel app gains more from pulling WireMock's standalone JAR in CI than from adopting an unmaintained Symfony bridge that will fight your container.
  • What to actually do: run WireMock standalone (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.
  • First use case: one flaky outbound HTTP dependency — an SMS provider, a payments gateway, a partner API — behind a Laravel feature test. Stub the response with __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().

Implementation Patterns

  • Prefer 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.
  • Lifecycle trait. Wrap the container in a PHPUnit trait: 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.
  • Stub mappings in 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.
  • Assert on requests via /__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.
  • Multiple instances = multiple base URLs. The bundle supports several WireMock servers; map that to per-service config keys (services.partner_a.base_uri, services.partner_b.base_uri) pointing at different ports. This keeps stubs isolated per integration.
  • Adapter around outbound clients. Bind Guzzle clients in a 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.
  • CI wiring. Add a WireMock service container to your pipeline (GitHub Actions 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.

Gotchas and Tips

  • It’s a Symfony bundle, not a Laravel package — full stop. No auto-discovery, no php artisan vendor:publish, no config merge. Fighting this wastes time; the concepts transfer, the wiring does not.
  • Archived + 1 star is a maintenance signal. No CVE handling, no release cadence, no upgrade path. If you did somehow integrate it, you own a fork. Do not make it load-bearing.
  • WireMock version drift. The bundle pins a WireMock server version. Standalone WireMock you run yourself may be newer, with admin API differences (/__admin/mappings payload shape, match operators). Pin the WireMock image tag explicitly and treat upgrades as a deliberate step.
  • Port collisions in parallel tests. WireMock defaults to 8080; parallel PHPUnit (--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.
  • Stub state leaks between tests. WireMock persists stubs and request journals until reset. Without 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.
  • Config quirks: 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.
  • Debugging: 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.
  • Extension points, in order of preference (assuming a Laravel-native WireMock helper): a 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.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
unabomber/timezone
delatbabel/contacts
astritzeqiri/g-recaptcha
kevinongko/laravel-genode
developeruz/laravel-analytics
robbiep/afterthedeadline
frankkessler/incontact-laravel-oauth2-rest
jlxh/laravel-userlog
davidmgilo/timetables
qylinfly/role-permission
reflect-digital/conduit
takashato/laravel-vietqr
aitor24/laralang
kraenzle-ritter/entity-relations
dindigital/din-image
pomirleanu/image-colors
sawmainek/laravel-api-generator
delatbabel/jsonresponses
mouhamedfd/permissions-generator
eduplus/qr