Name: filesystem
Owner: CakePHP
Description: [READ ONLY] Convenience library to help you work with files and folders.
Created: 2015-05-16 17:19:29.0
Updated: 2018-05-13 23:21:16.0
Pushed: 2018-05-21 01:31:57.0
Homepage: null
Size: 66
Language: PHP
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
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.
Create a folder instance and search for all the .ctp
files within it:
Cake\Filesystem\Folder;
= new Folder('/path/to/folder');
es = $dir->find('.*\.ctp');
Now you can loop through the files and read from or write/append to the contents or simply delete the file:
ach ($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
Please make sure you check the official documentation