PHPackages                             wwsh/vfs - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [File &amp; Storage](/categories/file-storage)
4. /
5. wwsh/vfs

ActiveLibrary[File &amp; Storage](/categories/file-storage)

wwsh/vfs
========

Simple, iterable, emulated file system iterator for PHP apps

013PHP

Since Mar 1Pushed 10y ago1 watchersCompare

[ Source](https://github.com/wwsh/vfs)[ Packagist](https://packagist.org/packages/wwsh/vfs)[ RSS](/packages/wwsh-vfs/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

VFS File System Iterator
========================

[](#vfs-file-system-iterator)

A Virtual File System (VFS) directory iterator for PHP, compatible with the API of RecursiveDirectoryIterator and DirectoryIterator, able to mimic original class behaviour, while creating a virtual, non-existent file system from a PHP array.

Input
-----

[](#input)

Factory accepts two parameters:

- string or array: either path to a JSON file, or array itself.
- (optional) the initial path to iterate, for example: "/music/oldies"

Array format
------------

[](#array-format)

Each key represents a directory, each value is the filename itself.

Structure example:

```
 '/music' => [
        '1993 Haddaway - What Is Love (Remixes)' => [
            "1 - Haddaway - What Is Love (7'' Mix).wav",
            "2 - Haddaway - What Is Love (Eat This Mix).wav",
            "3 - Haddaway - What Is Love (Tour De Trance Mix).wav"
        ],
        "1985 Paul Hardcastle - 19 (The Final Story) [601 814]" => [
            "01 - Paul Hardcastle - 19 (The Final Story).wav",
            "02 - Paul Hardcastle - 19 (Destruction Mix).wav"
        ]
    ]

```

JSON format
-----------

[](#json-format)

Identical. See **vfs-example.json** for an example.

Output
------

[](#output)

The following methods are supported and fully emulated:

```
public function getFilename();

public function getPath();

public function isDir();

public function isDot();

public function isFile();

public function current();

public function next();

public function valid();

public function getChildren();

public function hasChildren();

public function rewind();

```

See [**here**](http://php.net/manual/en/class.recursivedirectoryiterator.php) for original API explanation.

Example working code
--------------------

[](#example-working-code)

```
    $path = ... // define starting path
    $vfsArray = []; // paste the VFS array here. See above.
    $iterator = FileSystemFactory::create('vfs', [$path, $vfsArray]);
    $iterator->rewind();
    echo 'Browsing path ' . $iterator->getPath() . "...\n";

    while ($iterator->valid()) {
        $file = $iterator->current();

        if ($file->isDot() || $file->isFile()) {
            continue;
        }

        echo 'Processing directory ' . $file->getFilename() . "\n";
        // process (string)$file.....
        $results[] = $result;

        $iterator->next();
    }

```

Warnings
--------

[](#warnings)

Not designed to not use in **foreach** loops.

Notes
-----

[](#notes)

Licensed via MIT. Feel free to modify and contribute. Enjoy!

###  Health Score

19

—

LowBetter than 10% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/164b7f1eb72f3d5a4163d45239c0d985f5b80b9c83e821fe833a381386f82f64?d=identicon)[wwsh](/maintainers/wwsh)

### Embed Badge

![Health badge](/badges/wwsh-vfs/health.svg)

```
[![Health](https://phpackages.com/badges/wwsh-vfs/health.svg)](https://phpackages.com/packages/wwsh-vfs)
```

###  Alternatives

[knplabs/gaufrette

PHP library that provides a filesystem abstraction layer

2.5k39.8M123](/packages/knplabs-gaufrette)[google/cloud-storage

Cloud Storage Client for PHP

34390.8M125](/packages/google-cloud-storage)[illuminate/filesystem

The Illuminate Filesystem package.

15261.6M2.6k](/packages/illuminate-filesystem)[superbalist/flysystem-google-storage

Flysystem adapter for Google Cloud Storage

26320.6M30](/packages/superbalist-flysystem-google-storage)[creocoder/yii2-flysystem

The flysystem extension for the Yii framework

2931.7M62](/packages/creocoder-yii2-flysystem)[flowjs/flow-php-server

PHP library for handling chunk uploads. Works with flow.js html5 file uploads.

2451.6M15](/packages/flowjs-flow-php-server)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
