brainexploded / fstools
Installs: 18
Dependents: 1
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
pkg:composer/brainexploded/fstools
This package is not auto-updated.
Last update: 2025-09-28 02:05:18 UTC
README
FSTraverser
It is the class for recursive traverse your directories and apply callback to each found file.
Usage example:
$tr = new FSTraverser( // root dir '/home/user/lol', // callback function($path, $entry) { echo $entry, PHP_EOL; } ); $tr->setExcludeExtensions(['php', 'js']); $tr->go();
In this example, we print all files, that are not php or js.
Or:
$tr = new FSTraverser( // root dir '/home/user/lol', // callback function($path, $entry) { echo $entry, PHP_EOL; }, // exclude nodes ['.git', 'README.md'], // exclude extensions (have no point in this case, because allowed extensions are setted) ['zip', 'gz'], // allowed extensions (process only files with this extension) ['js', 'twig'], // maximal depth 5 ); $tr->go();
In this example, we traverse lol
directory, avoiding .git
dir and README.md
file, process only js and twig files, and not traverse all nodes, deeper than 5
level.