PHP code example of sweikenb / lib-fs

1. Go to this page and download the library: Download sweikenb/lib-fs 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/ */

    

sweikenb / lib-fs example snippets


$service = new \Sweikenb\Library\Filesystem\Service\DirectoryTreeService();
$tree = $service->fetchTree('/my/directory/to/fetch');

foreach($tree->getChildDirs() as $dir) {
    foreach ($dir->getFiles() as $file) {
        // recursive function needed to traverse the tree
    }
}
foreach ($tree->getFiles() as $file) {
    $content = $file->getContent();
    // do some mods to the content ...
    $file->setContent($content);
}

$tree->persist();