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.
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:
Key questions:
filesystem or cache configurations (e.g., in config/filesystems.php)?Stack fit:
vendor/ or bootstrap/ paths.Migration path:
0.2.5 via Composer (composer require infection/include-interceptor:0.2.5).phpunit.xml):
<php>
<includePath>./vendor/infection/include-interceptor/bootstrap.php</includePath>
</php>
include/require in a dummy test class to confirm instrumentation works without autoloader conflicts.Compatibility:
Filesystem or Laravel’s Illuminate/Filesystem.Sequencing:
app()->environment('testing')).Maintenance:
README section for Laravel-specific setup (e.g., bootstrap timing, conflict examples).Support:
Scaling:
--parallel).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:
composer.json and configure in phpunit.xml; validate with a simple test case.How can I help you explore Laravel packages today?