Weave Code
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

Plugin Mock Laravel Package

guzzle/plugin-mock

guzzle/plugin-mock provides a mock plugin for Guzzle, letting you queue predefined responses and simulate HTTP requests during testing. Useful for isolating API clients, reproducing edge cases, and running fast, reliable unit tests without real network calls.

View on GitHub
Deep Wiki
Context7

Product Decisions This Supports

  • Accelerated API/Service Development: Enables rapid prototyping and testing of HTTP-based integrations (e.g., third-party APIs, microservices) without relying on live endpoints. Reduces dependency on external systems during early-stage development or CI/CD pipelines.
  • Cost-Effective Testing: Eliminates the need for paid API sandboxes or mock services for unit/integration tests, lowering infrastructure costs.
  • Risk Mitigation: Safeguards against flaky tests caused by rate limits, downtime, or throttling in production APIs. Ensures deterministic test environments.
  • Build vs. Buy: Justifies in-house implementation over commercial mocking tools (e.g., Postman Mock Server, WireMock) when:
    • Budget constraints exist.
    • Custom mocking logic is required (e.g., dynamic responses based on test data).
    • The team already uses Guzzle for HTTP requests.
  • Roadmap Prioritization: Aligns with initiatives like:
    • Migrating legacy monoliths to microservices (mock external dependencies).
    • Scaling QA efforts for high-volume API consumers (e.g., mobile apps, IoT devices).
    • Compliance testing (e.g., GDPR data deletion flows where real APIs can’t be used).

When to Consider This Package

Adopt when:

  • Your stack heavily uses Guzzle (v3) for HTTP requests, and you need lightweight, PHP-native mocking.
  • You’re building internal tools, SDKs, or libraries where API contracts must be tested in isolation.
  • Your tests require fine-grained control over request/response cycles (e.g., simulating edge cases like 429 errors or malformed payloads).
  • You prioritize developer velocity over enterprise-grade mocking features (e.g., no need for persistent mock servers or advanced traffic shaping).

Look elsewhere if:

  • You need Guzzle v7+ support (this package is for v3 only; consider php-mock-http or vcr for modern versions).
  • Your use case demands stateful mocks (e.g., tracking sequential requests) or performance testing (this is read-only; use tools like k6 or Locust).
  • You require GUI-based mocking (e.g., for API designers) or collaborative mocking (e.g., shared mocks across teams).
  • Your team lacks PHP expertise; this package assumes familiarity with Guzzle’s internals and PSR standards.

How to Pitch It (Stakeholders)

For Executives: "This package lets our engineering team build and test API integrations faster and cheaper by replacing real-world dependencies with controlled, in-code simulations. For example, instead of waiting for a payment processor’s sandbox to be available—or paying for a commercial mocking tool—we can spin up realistic API responses in seconds. This directly supports [X initiative], reducing time-to-market for [Y feature] by [Z%]. The cost? Near-zero: it’s open-source and leverages our existing Guzzle investment. Risks? Minimal—we’re not locking into a vendor, and the team can iterate without external constraints."

For Engineering: *"guzzle/plugin-mock gives us a lightweight, deterministic way to test HTTP logic without touching production or paid services. Key wins:

  • No more flaky tests: Mock responses are consistent and repeatable.
  • Faster onboarding: New hires can test API interactions immediately without setup.
  • Flexible: We can simulate errors, delays, or custom payloads (e.g., for A/B testing). Tradeoff: It’s Guzzle v3-only, so if we’re on v7+, we’ll need an alternative. But for now, it’s a drop-in solution for our [specific use case, e.g., payment gateway tests] that saves us [hours/week] in test maintenance."*

For QA/DevOps: *"This package eliminates bottlenecks in our CI pipeline by letting us:

  • Isolate API tests from external failures (e.g., Stripe downtime).
  • Replay historical responses for regression testing (when paired with VCR).
  • Automate edge-case testing (e.g., ‘What if the auth token expires?’) without manual intervention. Ask: Do we need to extend this for mocking non-Guzzle HTTP clients (e.g., cURL)? If so, we might need a wrapper layer."*
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.
terminal42/code-quality-tools
codifyo/ts-generator-bundle
andydefer/laravel-cluster
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity
christhompsontldr/laravel-inky