PHP code example of jhofm / flysystem-iterator

1. Go to this page and download the library: Download jhofm/flysystem-iterator library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

jhofm / flysystem-iterator example snippets


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));

'skip-root' => true

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