Instead of
vfsStreamWrapper::register();
vfsStreamWrapper::setRoot(vfsStream::newDirectory('root'));
you can simply do
vfsStream::setup()
which yields the same result. Additionally, the method returns the
freshly created root directory which you can use to make further
adjustments to it.
Assumed $structure contains an array like this:
array('Core' = array('AbstractFactory' => array('test.php' => 'some text content',
'other.php' => 'Some more text content',
'Invalid.csv' => 'Something else',
),
'AnEmptyFolder' => array(),
'badlocation.php' => 'some bad content',
)
)
the resulting directory tree will look like this:
root \- Core |- badlocation.php |- AbstractFactory | |- test.php | |- other.php | \- Invalid.csv \- AnEmptyFolderArrays will become directories with their key as directory name, and strings becomes files with their key as file name and their value as file content.
public static setup ( string $rootDirName = 'root', integer $permissions = null, array $structure = [] ) : |
||
$rootDirName | string | name of root directory |
$permissions | integer | file permissions of root directory |
$structure | array | directory structure to add under root directory |
return |