Nouvelle librairie de gestion de fichiers, vos avis sont les bienvenus

Petit nouveau ! | 1 Messages

28 avr. 2024, 22:56

I really enjoyed using the path lib when I was working with files in python, so I decided to try to create something similar in PHP: path-php

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!

To install :

Code : Tout sélectionner

composer require olinox14/path-php
/!\ PHP8.0+ required