PHPackages                             jhofm/flysystem-iterator - 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. jhofm/flysystem-iterator

Abandoned → [league/flysystem](/?search=league%2Fflysystem)Library[File &amp; Storage](/categories/file-storage)

jhofm/flysystem-iterator
========================

Iterator plugin for league/flysystem

v2.2.1(5y ago)434.7k↓33.3%2MITPHPPHP ^7.0CI failing

Since Apr 10Pushed 5y ago1 watchersCompare

[ Source](https://github.com/jhofm/flysystem-iterator)[ Packagist](https://packagist.org/packages/jhofm/flysystem-iterator)[ RSS](/packages/jhofm-flysystem-iterator/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (9)Dependencies (3)Versions (11)Used By (2)

flysystem-iterator (deprecated)
===============================

[](#flysystem-iterator-deprecated)

Deprecation
-----------

[](#deprecation)

This package is deprecated. [league/flysystem v2.0](https://packagist.org/packages/league/flysystem#2.0.0) supports filterable recursive iterators [out of the box](https://flysystem.thephpleague.com/v2/docs/usage/directory-listings/). You can still use this plugin if for some reason you are unable to upgrade from version v1.x.

About
-----

[](#about)

Provides a plugin that creates an Iterator to iterate over paths in a [Flysystem](https://github.com/thephpleague/flysystem/tree/1.x)\\[FileSystem](https://github.com/thephpleague/flysystem/blob/1.x/src/Filesystem.php), supporting recursion and custom filters.

Recursive iteration is more memory-efficient than Flysystem's recursive listContents lookup (`$filesystem->listContents('', true)`), since only directory contents that are part of the current item's ancestry are kept in memory.

The returned iterator is seekable, countable and jsonserializable. Using these functions will often require a complete recursion over all items in the filesystem.

Requirements
------------

[](#requirements)

- PHP 7.0 - 7.4

Installation
------------

[](#installation)

The library can be added to your project via composer.

```
$ composer require jhofm/flysystem-iterator
```

Quick Start
-----------

[](#quick-start)

```
use Jhofm\FlysystemIterator\Plugin\IteratorPlugin;
use League\Flysystem\Adapter\Local as LocalAdapter;
use League\Flysystem\Filesystem;
use Jhofm\FlysystemIterator\Filter\FilterFactory;

$fs = new Filesystem(
    new LocalAdapter(
        '/home/user',
        LOCK_EX,
        LocalAdapter::SKIP_LINKS
    )
);
$fs->addPlugin(new IteratorPlugin());

$iterator = $fs->createIterator(
    ['filter' => FilterFactory::isFile()],
    'subdirectory'
);

foreach ($iterator as $key => $item) {
    echo $i . ' ' . $item['path'] . "\n";
}
var_dump(json_encode($iterator));

```

Configuration options
---------------------

[](#configuration-options)

Iterator behaviour can be controlled by passing a key/value configuration array to the plugin. Constants exist in the Options\\Options class for all available option keys and string values.

Iterator recursion is enabled by default, and can be disabled by passing:

```
'recursive' => false

```

When recursion is enabled, the first value returned by the iterator will be the directory that is iterated over. To ignore the root directory and start iteration with the directories contents you can pass the parameter

```
'skip-root' => true

```

This parameter has no effect if recursion is disabled.

The iterator will return a numerical index as the key and the file information array returned by listContents() for the current item.

Additional filesystem metadata can be added to the items by passing an array of additional properties to the configuration array. Allowed property names are the same as in Flysystem's ListWith plugin.

```
'list-with' => 'mimetype'

```

Alternatively, the path of the current item, relative to the directory being iterated, may be returned as the value instead of the info array. Unlike the paths in filesystem's info array directories will have a trailing slash, so it is possible to distinguish files from directories without the type information.

```
'value' => 'path'

```

The paths that the iterator returns can be filtered by passing a filter closure. The current list item is passed to the filter. The item will be included in the result if the closure returns true. The following example only returns files (directories are skipped) with a size of 1kb or more.

```
[
    'filter' =>
        function(array $item) {
            return $item['type'] === 'file'
            && $item['size'] >= 1024;
        }
]

```

A filter factory is included that provides a number of ready to use filter callbacks, including boolean wrappers.

```
[
    'filter' =>
        FilterFactory::and(
            FilterFactory::isDirectory(),
            FilterFactory::pathContainsString('foo')
        )

```

A subdirectory can be specified as an optional second parameter to the createIterator() function. If omitted, the iterator will use the directory set by the filesystem adapter.

Known Issues
------------

[](#known-issues)

- Filters do not work with path return values

###  Health Score

34

—

LowBetter than 77% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity29

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity61

Established project with proven stability

 Bus Factor1

Top contributor holds 96.2% of commits — single point of failure

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.

###  Release Activity

Cadence

Every ~78 days

Recently: every ~153 days

Total

9

Last Release

1970d ago

Major Versions

v1.1.1 → v2.0.02019-04-20

PHP version history (2 changes)v1.0PHP ^7.1

v2.1.0PHP ^7.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/e045a9a1c560eed33f74acc626f6756780538a55988e9f5741d6d14b0f23daca?d=identicon)[jhofm](/maintainers/jhofm)

---

Top Contributors

[![jhofm](https://avatars.githubusercontent.com/u/8502402?v=4)](https://github.com/jhofm "jhofm (25 commits)")[![BusterNeece](https://avatars.githubusercontent.com/u/6744885?v=4)](https://github.com/BusterNeece "BusterNeece (1 commits)")

---

Tags

composerdirectoriesdirectory-traversaldirectory-treefilesystemflysystemflysystem-pluginiteratorrecursionrecursive

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/jhofm-flysystem-iterator/health.svg)

```
[![Health](https://phpackages.com/badges/jhofm-flysystem-iterator/health.svg)](https://phpackages.com/packages/jhofm-flysystem-iterator)
```

###  Alternatives

[league/flysystem-aws-s3-v3

AWS S3 filesystem adapter for Flysystem.

1.6k263.6M790](/packages/league-flysystem-aws-s3-v3)[unisharp/laravel-filemanager

A file upload/editor intended for use with Laravel 5 to 10 and CKEditor / TinyMCE

2.2k3.3M74](/packages/unisharp-laravel-filemanager)[league/flysystem-local

Local filesystem adapter for Flysystem.

225231.8M39](/packages/league-flysystem-local)[league/flysystem-bundle

Symfony bundle integrating Flysystem into Symfony applications

40129.5M87](/packages/league-flysystem-bundle)[league/flysystem-sftp-v3

SFTP filesystem adapter for Flysystem.

6129.6M91](/packages/league-flysystem-sftp-v3)[league/flysystem-memory

In-memory filesystem adapter for Flysystem.

8533.6M194](/packages/league-flysystem-memory)

PHPackages © 2026

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