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

Product Decisions This Supports

  • Mutation Testing & Code Quality: Enables rapid integration of Infection or custom mutation testing frameworks into Laravel projects, reducing false positives in test coverage by dynamically intercepting and replacing file inclusions. This directly supports quality-focused roadmap items like "Improve test reliability" or "Reduce flaky tests."
  • Debugging & Observability: Accelerates debugging of autoloading issues (e.g., missing files, circular dependencies) by allowing real-time inspection of included files during test execution. Critical for enterprise Laravel apps with complex dependency graphs.
  • Security & Compliance: Facilitates runtime code analysis (e.g., detecting unauthorized include calls in user-uploaded templates or third-party libraries) without modifying production code. Aligns with security roadmap goals like "Prevent arbitrary file inclusion vulnerabilities."
  • Build vs. Buy: Eliminates the need to develop custom stream wrapper logic (3–6 months of effort) for tools like mutation testing or static analyzers. The package’s BSD-3-Clause license and proven use in Infection reduce risk for teams evaluating open-source alternatives.
  • Test Infrastructure: Enables dynamic test instrumentation (e.g., injecting mocks into final classes via dg/bypass-finals) without modifying source code, supporting test-driven development (TDD) and legacy code modernization.

When to Consider This Package

Adopt When:

  • Building mutation testing tools (e.g., Infection, custom PHPStan extensions) where file inclusion interception is core functionality.
  • Debugging autoloading issues in Laravel apps with complex Composer dependencies (e.g., plugins, legacy codebases).
  • Monitoring third-party library behavior (e.g., tracking which files a vendor package includes during tests).
  • Prioritizing low-code solutions for runtime code analysis (e.g., security scanners, performance profilers).
  • Working in test environments where file inclusion visibility is required for accurate test coverage or mutation analysis.

Look Elsewhere When:

  • No need for runtime file interception: Standard Laravel workflows (e.g., API routes, Blade templates) don’t require this level of granularity.
  • Targeting PHP 8.2+: The package’s last major release (2021) may lack compatibility with newer PHP features (e.g., attributes, enums).
  • Requiring advanced AST manipulation: For deep code transformation (e.g., rewriting classes at runtime), consider Nikic’s PHP-Parser or Rector instead.
  • Avoiding stream wrapper complexity: If the team lacks experience with PHP’s stream system, alternatives like Xdebug or custom autoloader hooks may be simpler.
  • Production use: Not designed for runtime Laravel apps—only for test/CLI contexts.

Red Flags:

  • Stalled maintenance: While the 0.2.5 fix (2026) addresses a critical bug, the 5-year gap since 1.0.0 suggests limited long-term investment. Monitor for updates or fork if critical.
  • Laravel-specific risks: Potential conflicts with Symfony’s Filesystem or Laravel’s caching layer if misconfigured (e.g., premature registration).
  • No Laravel integration: Requires manual setup (e.g., phpunit.xml bootstrapping), unlike Laravel-first packages.

How to Pitch It (Stakeholders)

For Executives:

"This package lets us ship high-impact code quality features in weeks instead of months—like mutation testing or security scanners—that would otherwise require 6+ months of custom engineering. It’s already battle-tested in Infection, a leading PHP mutation testing tool, and the recent 0.2.5 fix proves the team is responsive to critical issues. By adopting this, we reduce technical debt while accelerating our roadmap for test reliability, security, and legacy code modernization—all with a permissive license and zero runtime cost in production."

Key Metrics to Highlight:

  • Time savings: 3–6 months of engineering effort avoided.
  • Risk reduction: Proven in production (Infection), with recent maintenance.
  • ROI: Enables enterprise-grade features (e.g., mutation testing) at a fraction of the cost.

For Engineering Teams:

*"This is a zero-configuration, high-impact tool for intercepting file inclusions in PHP—perfect for test instrumentation, debugging, and code analysis. Here’s why it’s a no-brainer:

  • Integrates in hours: Just add it to composer.json and bootstrap it in phpunit.xml. No deep PHP internals knowledge required.
  • Battle-tested: Used by Infection (mutation testing) and dg/bypass-finals (mocking final classes), so it’s stable and reliable.
  • Low overhead: Adds <2ms per include, negligible for test suites.
  • Fixes critical issues: The 0.2.5 lock constant fix resolves race conditions in parallel test runs (e.g., Pest).

Use Cases We Can Unlock:

  1. Mutation Testing: Integrate Infection to find flaky tests by mutating code and checking if tests still pass.
  2. Debugging: Track which files are included during tests to uncover missing test coverage.
  3. Security: Detect unauthorized include calls in third-party libraries or user uploads.
  4. Legacy Code: Rewrite include paths dynamically during migrations (e.g., old include 'config.php' → autoloader).

How to Start:

composer require --dev infection/include-interceptor

Then add this to your phpunit.xml:

<php>
    <includePath>./vendor/infection/include-interceptor/bootstrap.php</includePath>
</php>

Warning: Only use this in test/CLI environments—never in production."*

For PMs/TPMs:

  • Roadmap alignment: Ties to test quality, security, and legacy modernization.
  • Risk mitigation: Proven in Infection; recent fix reduces technical debt.
  • Team upskill: Low learning curve for PHP devs familiar with stream wrappers.
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.
calmfox/watch-sylius
damienfern/grpc-symfony-bundle
atoolo/index-bundle
atoolo/genai-bundle
coprotoai/laravel-ticket
davidjln/llm-carbon-bundle
cryonighter/valid-request-bundle
coolms/taxonomy-bundle
coolms/field-bundle
articulate-orm/symfony
aaix/laravel-tall-architect
ephoto/akeneo-connector
emmanuelballery/eb-plantumlbundle
emielburgman/symfony-visitor-beacon
emielburgman/symfony-visit-storage
emielburgman/symfony-security-headers
emielburgman/symfony-log-viewer
emarref/xdebug-bundle
emarref/pubnub-bundle
elriseio/finance-money-bundle