2017 © Pedro Peláez
 

library fstools

image

brainexploded/fstools

  • Thursday, December 8, 2016
  • by brainexploded
  • Repository
  • 1 Watchers
  • 0 Stars
  • 4 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

Tools for work with filesystem

FSTraverser

It is the class for recursive traverse your directories and apply callback to each found file., (*1)

Usage example:, (*2)

$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., (*3)

Or:, (*4)

$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., (*5)

The Versions

08/12 2016

dev-master

9999999-dev

  Sources   Download

MIT