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

Include Interceptor Laravel Package

infection/include-interceptor

PHP stream wrapper that intercepts the file:// protocol to override the content of any included or autoloaded file at runtime. Register a mapping from original file to replacement, enable the interceptor, and includes/file_get_contents load the replacement instead.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture fit: Laravel's reliance on Composer autoloading minimizes direct include/require usage, making this package's utility limited to niche scenarios like mutation testing (e.g., Infection) or custom instrumentation. The fix in 0.2.5 (correcting the stream wrapper lock constant) resolves a critical edge case in file locking behavior, improving reliability for test environments where file inclusion monitoring is critical. The package remains misaligned with standard Laravel production practices but is now more robust for its intended use cases.

Integration feasibility: High for test environments if integrated via PHPUnit bootstrap or Infection setup. Early registration of the stream wrapper (e.g., in phpunit.xml or test bootstrap files) is still required, but the lock constant fix mitigates potential race conditions or corrupted file states during instrumentation. Conflicts with Composer's autoloader remain a risk if the wrapper is registered prematurely, though this is now less likely to manifest as silent failures.

Technical risk:

  • Low for test environments: The lock constant fix reduces the risk of file corruption during parallel test execution or instrumentation.
  • Moderate for custom setups: Stream wrapper registration timing remains critical; improper sequencing could still disrupt autoloading.
  • None for production: No impact on Laravel's core workflows.

Key questions:

  1. Does the package’s stream wrapper interfere with Laravel’s filesystem or cache configurations (e.g., in config/filesystems.php)?
  2. How does the lock constant change affect performance in high-concurrency test suites (e.g., Pest or parallel PHPUnit)?
  3. Are there Laravel-specific test tools (e.g., Laravel Zero, custom test runners) that could conflict with this package’s stream wrapper?

Integration Approach

Stack fit:

  • Test-focused: Ideal for Laravel projects using Infection, custom mutation testing, or static analysis tools requiring file inclusion tracking.
  • Non-production: Explicitly not designed for runtime Laravel applications; avoid in vendor/ or bootstrap/ paths.
  • Composer compatibility: No breaking changes to Composer integration; autoloader remains unaffected.

Migration path:

  1. Update package: Replace existing version with 0.2.5 via Composer (composer require infection/include-interceptor:0.2.5).
  2. Re-register wrapper: Ensure the stream wrapper is initialized after Composer autoloading in test bootstraps (e.g., phpunit.xml):
    <php>
        <includePath>./vendor/infection/include-interceptor/bootstrap.php</includePath>
    </php>
    
  3. Validate: Test with a sample include/require in a dummy test class to confirm instrumentation works without autoloader conflicts.

Compatibility:

  • Laravel 8+: No known conflicts with Symfony’s Filesystem or Laravel’s Illuminate/Filesystem.
  • PHP 8.0+: Lock constant fix aligns with modern PHP’s file locking semantics.
  • Tooling: Explicitly tested with Infection; may require adjustments for other mutation testers (e.g., PHPStan extensions).

Sequencing:

  1. Critical order: Stream wrapper must register after Composer’s autoloader but before test execution.
  2. Avoid global scope: Restrict to test environments using environment checks (e.g., app()->environment('testing')).

Operational Impact

Maintenance:

  • Low: No breaking changes; update via Composer. Monitor for Infection or PHPUnit version skew.
  • Documentation: Add a README section for Laravel-specific setup (e.g., bootstrap timing, conflict examples).

Support:

  • Test environments: Primary use case; support limited to file inclusion monitoring scenarios.
  • Production: No support needed; package is opt-in for tests only.

Scaling:

  • Parallel tests: Lock constant fix reduces race conditions in concurrent test suites (e.g., Pest’s --parallel).
  • Resource usage: Stream wrapper adds minimal overhead (~1–2ms per include); negligible for most test suites.

Failure modes:

Scenario Impact Mitigation
Premature wrapper registration Autoloader corruption Use phpunit.xml or test bootstrap.
File locking deadlocks Test hangs/corruption Avoid in CI with high concurrency.
Infection/PHPUnit version skew Undefined behavior Pin versions in composer.json.

Ramp-up:

  • For TPMs: No action required unless adopting mutation testing; evaluate as a test dependency.
  • For Devs: Add to composer.json and configure in phpunit.xml; validate with a simple test case.
  • Training: Highlight use case (e.g., "This package is for test instrumentation only; do not use in production.").
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.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
milesj/emojibase
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport