The objective here is to create a light, standalone, multi-platform lib for PHP, allowing to handle paths as objects.
Using it allows you to make things like :
Code : Tout sélectionner
$path = new Path(__file__);
$dir = $path->parent();
foreach($dir->files() as $file) {
if ($file->ext() === 'html') {
$file->rename($file->name() . '.md');
}
}
Although most of the provided methods are proxies to the builtin PHP methods, it also tries to provide some other commonly required functions that are missing in the native PHP methods, like a copyTree or a recursive rmdir method.
Another objective is to throw proper exceptions when handling files, by explicitly throwing FileNotFoundException or FileExistsException when needed.
Any feedback would be really welcome, thanks!
github[dot]com/olinox14/path-php
To install :
Code : Tout sélectionner
composer require olinox14/path-php
/!\ PHP8.0+ required