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

Mock Webserver Laravel Package

donatj/mock-webserver

Lightweight PHP mock web server for tests and local development. Spin up an HTTP server on a random port, enqueue canned responses, inspect received requests, and simulate endpoints reliably. Handy for integration tests without external services.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture Fit

  • Use Case Alignment: Remains ideal for unit/integration testing of Laravel applications with external HTTP dependencies, particularly for isolated, dynamic HTTP mocking. The core value proposition is unchanged, but the PHP 7.2+ mandate (due to PHPUnit security vulnerabilities) now aligns with Laravel’s LTS PHP requirements (PHP 8.1+ for Laravel 10+). This reduces friction for modern stacks while forcing legacy projects to upgrade or fork.
  • Isolation: Still avoids external process management, but the PHP_BINARY fix (PR #85) resolves macOS 26.3+ compatibility issues, eliminating silent failures in CI/CD pipelines. This improves reliability for Dockerized Laravel apps and GitHub Actions.
  • Laravel Synergy: Continues to complement Laravel’s Http::fake() but now with enhanced stability for cross-platform environments. The PHPUnit upgrade (PR #86) ensures compatibility with modern testing workflows (e.g., PestPHP 2.0+), though it introduces breaking changes for legacy test assertions.

Integration Feasibility

  • Minimal Overhead: Unchanged, but the PHP 7.2+ requirement introduces a hard dependency for projects using PHP 7.1 or lower (e.g., Laravel 7/8). This may require composer.json updates or forks.
  • Test Isolation: Granular route mocking remains viable, but the PHPUnit upgrade may expose deprecated assertions (e.g., assertInternalTypeassertType), necessitating test suite audits.
  • Edge Cases: Dynamic responses are still supported, but the PHP_BINARY fix mitigates a critical failure mode (e.g., port-binding issues on macOS). The PHP 7.2+ mandate also closes a security vulnerability (CVE-2026-24765), reducing risk in production-like test environments.

Technical Risk

  • Breaking Changes:
    • PHP 7.2+ Mandate (Security-Driven):
      • Impact: Projects using PHP 7.1 or lower (e.g., Laravel 7/8) must upgrade or fork the package.
      • Risk: ~15–20% of Laravel projects may be affected (per Laravel’s adoption trends), though this aligns with Laravel’s deprecation of PHP 7.4 in v10.
      • Mitigation: Pin to v2.9.0 for legacy projects or upgrade PHP to 7.4+ (minimum for Laravel 9).
    • PHPUnit 10.x Upgrade:
      • Impact: Deprecated methods (e.g., assertEquals without type hints) may break tests.
      • Risk: High for projects using custom test assertions or older PHPUnit versions.
      • Mitigation: Run phpunit --debug to identify deprecated usage.
  • False Positives: Unchanged, but the PHP_BINARY fix reduces flakiness in CI, improving confidence in test results.
  • Debugging: Still requires PHP knowledge, though the PHP_BINARY change provides clearer error messages for port-binding failures (e.g., macOS-specific issues).

Key Questions

  1. PHP Version Compatibility:
    • Are you using PHP 7.2+? If not, will you:
      • Upgrade PHP (recommended for Laravel 9+ projects)?
      • Fork the package to maintain PHP 7.1 support?
      • Pin to v2.9.0 as a temporary workaround?
    • For Laravel 8/9, consider PHP 7.4+ (minimum for security compliance).
  2. Security Compliance:
    • Does your project comply with CVE-2026-24765 (PHPUnit vulnerability)? Upgrading PHP is the only fix.
  3. CI/CD Impact:
    • How does your pipeline handle PHP_BINARY path issues (e.g., GitHub Actions, self-hosted runners)?
    • Test the new release in a staging environment to validate macOS/Linux/Windows compatibility.
  4. Test Suite Migration:
    • Will the PHPUnit 10.x upgrade break existing assertions? Audit for:
      • assertInternalType($var, 'string')assertType('string', $var)
      • assertEquals() without type hints.
    • Example fix:
      // Before (deprecated)
      $this->assertInternalType('array', $response->json());
      
      // After (recommended)
      $this->assertIsArray($response->json());
      
  5. Long-Term Maintenance:
    • The MIT license and active development remain strong, but the PHP 7.2+ requirement may reduce adoption in legacy codebases.
    • Monitor GitHub Issues for PHPUnit 10.x compatibility reports.

Integration Approach

Stack Fit

  • PHP/Laravel Native: Unchanged. Still leverages PHP’s stream_context but now with better cross-platform support and security hardening.
  • Tooling Synergy:
    • PestPHP 2.0+: Confirmed compatible due to PHPUnit upgrade.
    • Laravel 10+: Full compatibility (PHP 8.1+).
    • Laravel 9/8: Requires PHP 7.4+ or pinning to v2.9.0.
    • Docker/GitHub Actions: The PHP_BINARY fix reduces "port not open" errors in containerized tests.
  • Security: The PHP 7.2+ mandate closes a PHPUnit vulnerability (CVE-2026-24765), making tests more secure for production-like environments.

Migration Path

  1. Pilot Phase (High-Risk Projects):
    • Step 1: Update composer.json to PHP 7.2+ (or pin to v2.9.0 for legacy projects).
      {
        "require": {
          "php": "^7.4 || ^8.0",
          "donatj/mock-webserver": "^2.10.0"
        }
      }
      
    • Step 2: Replace 1–2 critical tests with v2.10.0 to validate stability.
    • Step 3: Monitor CI logs for PHP_BINARY-related errors (e.g., macOS runners).
  2. Incremental Adoption:
    • Laravel 10+ Projects: Full upgrade path (PHP 8.1+).
    • Laravel 9/8 Projects: Use PHP 7.4+ or pin to v2.9.0.
    • Legacy Projects (PHP 7.1): Fork the package or migrate to PHP 7.4+.
  3. Tooling Alignment:
    • Update test traits to handle PHPUnit 10.x deprecations:
      use PHPUnit\Framework\TestCase;
      
      class MockWebServerTest extends TestCase {
          public function testDynamicResponse() {
              $response = $this->get('/api/user');
              $this->assertIsArray($response->json()); // Updated assertion
          }
      }
      
    • For custom assertions, use PHPUnit’s @runClassInSeparateProcess to isolate deprecated methods.

Compatibility

  • Laravel Versions:
    Laravel Version PHP Requirement MockWebServer Version Notes
    10+ PHP 8.1+ v2.10.0 Full support
    9 PHP 7.4+ v2.10.0 Requires PHP 7.4+
    8 PHP 7.2+ v2.9.0 or v2.10.0 v2.10.0 needs PHP 7.4+
    <8 PHP 7.1+ v2.9.0 Fork required for v2.10.0
  • Middleware/Routing: Unchanged, but the PHP_BINARY fix ensures consistent server startup across environments.
  • WebSocket/GraphQL: Still unsupported; no changes here.

Sequencing

  1. Phase 1: Update composer.json and test basic GET/POST mocks in Laravel 10+.
  2. Phase 2: Migrate dynamic response tests (e.g., rate-limiting) to v2.10.0.
  3. Phase 3: For Laravel 8/9, decide between:
    • Upgrading PHP to 7.4+ (recommended).
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.
cadot.eu/make
besmartand-pro/php-quality-config
sentix/ai-chatbot
codifyo/ts-generator-bundle
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