mikey179/vfsstream
's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.Name | Version | Size | License | Type | Vulnerabilities |
---|
The mikey179/vfsStream Composer package is designed to provide a virtual file system that can be used in place of the real file system during unit testing. This allows developers to create mock files and directories, isolate tests from the system environment, and simplify the testing process significantly. It thus proves incredibly beneficial for applications making extensive use of the file system.
To use the mikey179/vfsStream package in your PHP code, you first need to install it via Composer. Here is an example of how you might do this:
composer require mikey179/vfsStream
Once installed, you can import and use it within your unit tests as follows:
Here is a basic usage example:
<?php
require 'vendor/autoload.php';
use org\bovigo\vfs\vfsStream;
$root = vfsStream::setup('root');
$file = vfsStream::newFile('test.txt')->at($root)->setContent('Hello, World!');
The vfsStream::setup('root')
call creates a new directory named 'root' on the virtual file system. The next line creates a new file named 'test.txt', places it in the 'root' directory, and sets its content to 'Hello, World!'.
Documentation for the mikey179/vfsStream package can be found on the project's GitHub Wiki. This wiki provides a comprehensive overview of the package, including its functional aspects, installation instructions, usage examples, frequently asked questions, and more. For additional insight, consider visiting the vfsStream Examples repository, which contains practical examples of vfsStream usage.