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

Http Message Implementation Laravel Package

psr-mock/http-message-implementation

Lightweight PSR-7 HTTP message implementation mock for testing libraries and SDKs without hard dependencies. Strictly follows PSR behavior and includes a developer-friendly API to debug and fix failing tests faster. For dev use only (PHP 8.1+).

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture Fit

  • Use Case Alignment: Remains ideal for testing Laravel applications with HTTP clients (Guzzle, Symfony HTTP Client) or middleware requiring PSR-7-compliant mocks. PHP 8.1+ alignment ensures compatibility with modern Laravel (v9+) and PHP ecosystems.
  • PSR-7 Compliance: Laravel’s PSR-7-compliant HTTP layer (Illuminate\Http\Request, Illuminate\Http\Response) continues to integrate seamlessly, though PHP 8.1’s stricter typing may expose edge cases in custom mock logic.
  • Isolation: Still enables clean separation of HTTP-related logic, but PHP 8.1’s features (e.g., named arguments, constructor property promotion) may require updates to existing mock builders.

Integration Feasibility

  • Low Friction: Installation remains trivial (composer require psr-mock/http-message-implementation), but PHP 8.1+ requirement may block legacy Laravel 8.x projects (PHP 7.4+).
  • Laravel-Specific: Mocking Request/Response objects is unchanged, but PHP 8.1’s type system may surface issues with Laravel’s extensions (e.g., Jsonable, File uploads) if not explicitly tested.
  • Tooling Synergy: Continues to work with PHPUnit/Pest, but PHP 8.1’s attributes (e.g., #[\Override]) may require adjustments in test assertions or mock setups.

Technical Risk

  • PHP 8.1 Enforcement: Breaking change for teams on PHP <8.1 (e.g., Laravel 8.x). Validate compatibility with your stack early.
  • PSR-7 Strictness: PHP 8.1’s stricter type checking may expose unhandled edge cases (e.g., UploadedFile mocks, custom headers with non-string values).
  • Dependency Conflicts: Risk of version mismatches with other PSR-7 libraries (e.g., nyholm/psr7) persists, but PHP 8.1’s stricter autoloading may reduce ambiguity.
  • Limited Adoption: Still unproven; spike test with PHP 8.1+ required to confirm stability.

Key Questions

  1. PHP Version Compatibility: Does your Laravel project (or CI/CD) support PHP 8.1+? If not, is this a blocker or acceptable trade-off?
  2. Test Coverage Scope: Will PHP 8.1’s features (e.g., union types, attributes) require updates to existing mock logic?
  3. Laravel-Specific Needs: Are there PHP 8.1-related changes in Laravel’s HTTP layer (e.g., new traits/interfaces) that need mocking?
  4. Long-Term Maintenance: With PHP 8.1 as a hard requirement, is the package’s future aligned with your tech stack’s roadmap?
  5. Performance Impact: Does PHP 8.1’s JIT or other optimizations affect mock generation/assertion performance?

Integration Approach

Stack Fit

  • PHP/Laravel Ecosystem: Now exclusively for Laravel v9+ or custom PHP 8.1+ projects. For Laravel 8.x, evaluate alternatives (e.g., php-mock/psr7-mock).
  • Testing Frameworks: Compatible with PHPUnit/Pest on PHP 8.1+, but PHP 8.1’s new features (e.g., attributes) may require test updates.
  • CI/CD: Requires PHP 8.1+ in CI pipelines; no additional runtime dependencies.

Migration Path

  1. Phase 0: PHP Version Gate
    • Audit Laravel/PHP version compatibility. Abort if PHP <8.1 is required.
    • Update composer.json to enforce PHP 8.1+:
      "require": {
          "php": "^8.1",
          "psr-mock/http-message-implementation": "^1.0"
      }
      
  2. Phase 1: Spike Test (PHP 8.1)
    • Replace 1–2 HTTP mocks with the new library, focusing on:
      • PSR-7 edge cases (e.g., UploadedFile, streaming responses).
      • Laravel-specific extensions (e.g., Jsonable, signed requests).
    • Test with PHP 8.1’s strict mode enabled (-dzend.assertions=1).
  3. Phase 2: Incremental Adoption
    • Refactor test suites to use the mock builder, leveraging PHP 8.1 features (e.g., named arguments in mock assertions).
    • Update CI to use PHP 8.1.
  4. Phase 3: Full Integration
    • Replace all PSR-7 mocks; deprecate old mocks.
    • Document PHP 8.1-specific quirks (e.g., null vs. false in headers).

Compatibility

  • PSR-7 Compliance: Unchanged, but PHP 8.1’s type system may reject loosely typed mocks (e.g., array headers must be string[]).
  • Guzzle/Symfony Clients: Works as before, but PHP 8.1’s stricter error handling may surface issues in client integrations.
  • Middleware Testing: Simplifies mocking, but PHP 8.1’s attributes may require updates to middleware test assertions.

Sequencing

  1. Prioritize PHP 8.1 Projects: Focus on Laravel v9+ or custom PHP 8.1+ apps first.
  2. Isolate Changes: Use feature flags to toggle between old/new mocks during transition.
  3. Performance Benchmark: Compare test execution time on PHP 8.0 vs. 8.1 to validate no regressions.
  4. Rollback Plan: Maintain legacy mocks temporarily; if PHP 8.1 adoption is blocked, consider php-mock/psr7-mock as a fallback.

Operational Impact

Maintenance

  • Low Overhead: Minimal maintenance, but PHP 8.1’s evolving features (e.g., enums, attributes) may require future updates.
  • Documentation: Limited docs; create internal runbooks for PHP 8.1-specific mocking (e.g., typed properties, constructor promotion).
  • Dependency Updates: Monitor for breaking changes in PSR-7 or Laravel’s HTTP layer, especially with PHP 8.2+.

Support

  • Community: Still limited; PHP 8.1 requirement may reduce adoption further.
  • Internal Knowledge: Team must ramp up on PHP 8.1’s type system and PSR-7 mocking patterns.
  • Debugging: Edge cases (e.g., UploadedFile mocks) may require deeper debugging due to PHP 8.1’s stricter checks.

Scaling

  • Test Suite Growth: Scales well, but PHP 8.1’s JIT may improve performance in large suites.
  • Parallel Testing: No known bottlenecks; PHP 8.1’s parallelism improvements may help.
  • Performance: Mock generation remains fast; PHP 8.1’s optimizations may reduce overhead.

Failure Modes

  • PHP Version Blockers: Hard requirement for PHP 8.1+ may halt adoption in legacy stacks.
  • PSR-7 Deviations: Laravel’s extensions (e.g., Jsonable) may still need custom mock logic.
  • Library Abandonment: Risk persists; mitigate with forks or alternatives (e.g., php-mock/psr7-mock).
  • Test Fragility: PHP 8.1’s stricter typing may break existing mock assertions (e.g., null headers).

Ramp-Up

  • Onboarding: 2–3 days for team to learn PHP 8.1’s type system + mock builder API.
  • Training: Focus on:
    • PHP 8.1’s constructor property promotion (affects mock builders).
    • Typed properties in PSR-7 interfaces.
    • Union types in mock assertions.
  • Documentation: Create cheat sheets for:
    • Mocking UploadedFile with PHP 8.1’s TempFile.
    • Handling null vs. false in headers.
  • Feedback Loop: Gather input on PHP 8.1-specific pain points (e.g., Attribute usage in tests).
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.
nasirkhan/laravel-sharekit
directorytree/privacy-filter-classifier
directorytree/privacy-filter
datacore/hub-sdk
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony
develia/geo-bundle
dreamzy/livewire-charts
touchestate-sdk/php-sdk
22h/doctrine-garbage-collection-bundle
agtp/agtp-php
agtp/mod-php
splash/sonata-admin
splash/metadata
splash/openapi
splash/scopes
splash/toolkit
testo/output-teamcity
testo/bridge-symfony