adlawson/vfs
Virtual file system for PHP using the stream wrapper API. Mount a vfs:// scheme and use built-in functions (fopen, require, file_get_contents) or filesystem libraries like Symfony/Laravel. Emulates real streams, including PHP warnings and edge cases.
Illuminate\Filesystem, League\Flysystem, or custom storage adapters without side effects.require or include virtual files for plugin systems, templating engines, or runtime-generated PHP (e.g., Laravel’s Blade caching).Adopt if:
eval().Look elsewhere if:
file_exists() call) and a mock object (e.g., Mockery) or Laravel’s Storage::fake() suffices.webmozart/path-util for path manipulation, or php-vfsstream as a fork with updates).Storage::fake()) for 80% of your needs and only require VFS for edge cases.*"This package lets us test and debug filesystem-dependent features—like file uploads, storage drivers, or caching—without touching the real disk. It’s like a sandbox for files, saving time in development and CI/CD by eliminating flaky tests caused by disk I/O or external storage. For example:
Ask: Should we pilot this in our storage driver tests and plugin system to measure impact on test speed and reliability? The cost is minimal (a Composer dependency), and the upside is fewer production bugs from untested filesystem logic."*
*"Why Use adlawson/vfs?
Storage, Flysystem, or custom file logic without side effects.eval().Illuminate\Filesystem, Storage facade, and third-party libraries like Symfony’s Filesystem.How to Adopt:
composer require adlawson/vfs
$fs = \Vfs\FileSystem::factory('vfs://');
$fs->mount();
// Now use `vfs://path/to/file` in tests.
Storage::fake('local');
Storage::disk('local')->put('test.txt', 'Hello');
$this->assertEquals('Hello', file_get_contents('vfs://test.txt'));
Trade-offs:
Proposal:
Alternatives:
Storage::fake() (simpler for basic cases).php-vfsstream (fork with updates, but less adoption).Next Steps:
Filesystem and Storage tests.*"How This Improves Your Work:
Example Workflow:
Ask: Should we train the team on using VFS for these high-priority test suites? It’s a small change with big payoffs for reliability."*
How can I help you explore Laravel packages today?