phellow/filesystem

Handles filesystem operations

1.0.0 2014-12-20 14:02 UTC

This package is auto-updated.

Last update: 2024-10-08 22:25:30 UTC


README

Add the following dependency to your project's composer.json file:

{
    "require": {
        "phellow/filesystem": "1.*"
    }
}

Usage

The FilesystemOperator is the main class to work with files and directories. You can add an object of this class to your Dependency Injection Container.

$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';
    }
}

To see all the possibilities, you can check out the Unit Tests under tests/.

License

The MIT license.