Download the PHP package phpfiletool/filetool without Composer
On this page you can find all versions of the php package phpfiletool/filetool. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download phpfiletool/filetool
More information about phpfiletool/filetool
Files in phpfiletool/filetool
Package filetool
Short Description A PHP library for file and directory management.
License GPL-3.0-or-later
Homepage https://github.com/AntonioCarioca/PHP-FileTool
Informations about the package filetool
PHP FileTool
PHP FileTool is a simple PHP library for working with files and directories.
It provides useful methods to create, read, write, copy, rename, list and delete files or directories using a clean static API.
Features
- Create files and directories
- Create multiple files at once
- Read and write file contents
- Copy files and file contents
- Copy all files from one directory to another
- Rename files and paths
- List directory files
- Delete files
- Delete empty directories
- Delete directories recursively
- Custom exceptions for safer error handling
- PSR-4 autoloading
- PHPUnit tests
- PHPStan static analysis
- PHPCS with PSR-12 standard
- GitHub Actions CI workflow
Requirements
- PHP 8.4 or higher
- Composer
Installation
Install the package with Composer:
Basic Usage
File Operations
Create a file
You can also pass the file extension separately:
Create multiple files
This creates files like:
Write to a file
The third argument controls overwrite mode:
Read a file
Copy a file
If the destination file already exists, PHP FileTool creates a unique name automatically:
Copy file content
Rename a file or path
Delete a file
Directory Operations
Create a directory
You can also define permissions:
List files in a directory
Copy all files from one directory to another
Delete all files from a directory
This removes files inside the directory, but keeps the directory itself.
Delete an empty directory
Delete a directory recursively
Be careful: this removes the directory and its contents recursively.
Exception Handling
PHP FileTool uses custom exceptions so you can handle errors more safely.
Available exceptions:
Facade Methods
The main facade is:
Main methods:
Legacy Method Aliases
For compatibility, some old method names are still available:
Prefer the new descriptive method names in new projects.
Development
Install dependencies:
Run tests:
Run PHPStan:
Run PHPCS:
Fix coding style automatically when possible:
Quality Tools
This project uses:
- PHPUnit for unit tests
- PHPStan for static analysis
- PHPCS for PSR-12 code style
- GitHub Actions for continuous integration
Changelog
See CHANGELOG.md for version history.
Contributing
Contributions are welcome.
Before opening a pull request, run:
Author
Antonio Silva
- GitHub: AntonioCarioca
- Blog: antoniosilva.hashnode.dev
License
This project is licensed under the GPL-3.0-or-later license.
See the LICENSE file for more details.