mscherer 256ac763f4 Fix CS: Use single quotes where applicable. 5 years ago
..
File.php 256ac763f4 Fix CS: Use single quotes where applicable. 5 years ago
Filesystem.php 3b9017f124 Updated description of Filesystem and clarify internal use only. 6 years ago
Folder.php e7a7da7b54 Updated all book.cakephp.org links to /4/ 6 years ago
LICENSE.txt 2083db428d Add/updte licenses and dates. 6 years ago
README.md e7a7da7b54 Updated all book.cakephp.org links to /4/ 6 years ago
composer.json 838bbdcc60 Update composer configs for split packages. 7 years ago

README.md

Total Downloads License

This package is 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