Simplifies using many of php's built-in filesystem functions
Find a file
2024-12-10 13:26:02 -06:00
lib Updated for php 8.4 2024-12-10 13:26:02 -06:00
tests Updated for php 8.4 2024-12-10 13:26:02 -06:00
.gitignore Updated with latest updates from upstream, added tests 2023-11-14 20:40:20 -06:00
.php-cs-fixer.php Updated with latest updates from upstream, added tests 2023-11-14 20:40:20 -06:00
AUTHORS Initial commit 2023-02-19 11:46:12 -06:00
composer.json Updated with latest updates from upstream, added tests 2023-11-14 20:40:20 -06:00
composer.lock Updated with latest updates from upstream, added tests 2023-11-14 20:40:20 -06:00
LICENSE Initial commit 2023-02-19 11:46:12 -06:00
README.md Initial commit 2023-02-19 11:46:12 -06:00
test Updated with latest updates from upstream, added tests 2023-11-14 20:40:20 -06:00

Filesystem

This is a fork of Symfony's Filesystem component which simplifies php's built-in filesystem functions. A common painpoint in using Symfony's component is that it is unnecessarily instantiated:

use Symfony\Component\Filesystem;
$fs = new Filesystem();
$fs->chmod('/path/to/file', 0600);

This is awkward because there isn't a reason to instantiate it. There's nothing within Filesystem to create an instance of. There's no defined constructor and no properties to set. In fact only a single static property exists within the class to store the last encountered error. It simply doesn't make any sense. It's especially curious considering the Path class that's included with Filesystem is itself a static class.

This fork eliminates that nonsense by making everything static:

use MensBeam\Filesystem as Fs;
Fs::chmod('/path/to/file', 0600);

Note

This library uses polyfills for ext-ctype and ext-mbstring. If you have these extensions installed the polyfills won't run. However, if you don't want the polyfills needlessly installed you can do this in your composer.json:

{
    "require": {
        "ext-ctype": "*",
        "ext-mbstring": "*"
    },
    "provide": {
        "symfony/polyfill-ctype": "*",
        "symfony/polyfill-mbstring": "*"
    }
}