cakephp/filesystem

CakePHP filesystem convenience classes to help you work with files and folders.

4.2.8 2021-05-20 16:24 UTC

This package is auto-updated.

Last update: 2021-07-17 02:21:01 UTC


README

Total Downloads License

This package has been deprecated.

CakePHP Filesystem Library

The Folder and File utilities are convenience classes to help you read from and write/append to files; list files within a folder and other common directory related tasks.

Basic Usage

Create a folder instance and search for all the .php files within it:

use Cake\Filesystem\Folder;

$dir = new Folder('/path/to/folder');
$files = $dir->find('.*\.php');

Now you can loop through the files and read from or write/append to the contents or simply delete the file:

foreach ($files as $file) {
    $file = new File($dir->pwd() . DIRECTORY_SEPARATOR . $file);
    $contents = $file->read();
    // $file->write('I am overwriting the contents of this file');
    // $file->append('I am adding to the bottom of this file.');
    // $file->delete(); // I am deleting this file
    $file->close(); // Be sure to close the file when you're done
}

Documentation

Please make sure you check the official documentation