PHP code example of phellow / filesystem

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

    

phellow / filesystem example snippets


$fs = new \Phellow\Filesystem\FilesystemOperator();

// create a directory if not exists
$fs->ensureDir('some/dir');

// copy file or directory
$fs->copy('someFile', 'newFile');
$fs->copy('some/dir', 'new/dir');

// get all files/directories of a directory
$files = $fs->getFiles('some/dir');
foreach ($files as $file) {
    if ($file->isFile()) {
        echo $file->path . ' is a file';
    } elseif ($file->isDirectory()) {
        echo $file->path . ' is a dir';
    } elseif ($file->isSymlink()) {
        echo $file->path . ' is a symlink';
    }
}