https://github.com/cakephp/filesystem
[READ ONLY] Convenience library to help you work with files and folders.
https://github.com/cakephp/filesystem
Last synced: 7 months ago
JSON representation
[READ ONLY] Convenience library to help you work with files and folders.
- Host: GitHub
- URL: https://github.com/cakephp/filesystem
- Owner: cakephp
- License: other
- Created: 2015-05-16T17:19:29.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2025-04-26T22:44:06.000Z (9 months ago)
- Last Synced: 2025-05-12T00:33:05.143Z (9 months ago)
- Language: PHP
- Size: 16.3 MB
- Stars: 20
- Watchers: 27
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
[](https://packagist.org/packages/cakephp/filesystem)
[](LICENSE.txt)
# 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:
```php
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:
```php
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](https://book.cakephp.org/4/en/core-libraries/file-folder.html)