Reputation: 29116
I would like to understand why I should use symfony/filesystem
and depend on a third-party package with:
$fileSystem->mkdir('/tmp/foo', 0700);
When I can simply do:
mkdir('/tmp/foo', 0700);
Is there any advantage that compensates the additional complexity I get?
Upvotes: 1
Views: 265
Reputation: 568
Basically, using the Symfony/Filesystem API, you have a more closely object-oriented approach and I can see, at least, 3 benefits:
1 - It makes easier to handle the directory creation itself. Just send which directory you want to create and mode.
2 - The errors are thrown as exceptions.
3 - It's easier to mock the mkdir
behavior when you are unit testing.
Upvotes: 1