Skip to content

Createcomplexstructures

mikey179 edited this page Jul 21, 2011 · 3 revisions

Create complex directory structures

Since version 0.10.0 one can create complex directory structures quite easily: $root = vfsStream::create($structure); 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
  \- AnEmptyFolder

Arrays 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.

Clone this wiki locally