Filesystem utilities pulled from Flaphl elements.
composer require flaphl/filesystem
- Cross-platform compatibility - Works seamlessly on Windows, macOS, and Linux
- Comprehensive file operations - Read, write, copy, move, delete with proper error handling
- Directory management - Create, remove, mirror directories recursively
- Path utilities - Normalize, join, and manipulate file paths safely
- Security features - Path traversal protection and validation
- Exception-driven - Clear error reporting with typed exceptions
use Flaphl\Element\Filesystem\Filesystem;
use Flaphl\Element\Filesystem\Path;
$fs = new Filesystem();
// Basic file operations
$fs->writeFile('/path/to/file.txt', 'Hello World!');
$content = $fs->readFile('/path/to/file.txt');
// Directory operations
$fs->mkdir('/path/to/directory');
$fs->copy('/source/directory', '/target/directory');
// Path utilities
$normalized = Path::normalize('/path/../to/./file.txt'); // '/to/file.txt'
$joined = Path::join('/base', 'subdir', 'file.txt'); // '/base/subdir/file.txt'