stk2k / file-system
A simle file system classes
0.2.3
2021-07-02 10:19 UTC
Requires
- php: >=7.2
- ext-json: *
Requires (Dev)
- mikey179/vfsstream: ^1.6.8
- php-coveralls/php-coveralls: ^2.0
- phpunit/phpunit: ^8.5.15
README
Description
A simle file system classes
Feature
- Simple file class(File)
- File function facade class(FileFacade)
Usage
making a file
use stk2k\filesystem\FileSystem; FileSystem::put('/path/to/file', 'Hello, World');
deleting a file
use stk2k\filesystem\FileSystem; FileSystem::delete('/path/to/file');
getting file's content
use stk2k\filesystem\FileSystem; // getting whole content as string $ret = FileSystem::get('/path/to/file'); echo $ret; // getting whole content as array $ret = FileSystem::getAsArray('/path/to/file'); print_r($ret);
putting file's content
use stk2k\filesystem\File; use stk2k\filesystem\FileSystem; // putting string content $ret = FileSystem::put('/path/to/file', 'Hello, World!'); echo $ret->get(); // Hello, World! // putting array(of strings) content $ret = FileSystem::put('/path/to/file', ['Foo', 'Bar']); echo $ret->get(); // Foo // Bar // putting File object file_put_contents('/path/to/file1', 'Hello, World!'); $ret = FileSystem::put('/path/to/file2', new File('/path/to/file1')); echo $ret->get(); // Hello, World! // putting object content(Stringable) class MyStringableObject { public function __toString() : string { return 'Hello, World!'; } } $ret = FileSystem::put('/path/to/file', new MyStringableObject()); echo $ret->get(); // Hello, World!
file object
use stk2k\filesystem\File; $ret = new File('/path/to/file'); echo $ret->get();
Requirement
PHP 7.2 or later
Installing stk2k/file-system
The recommended way to install stk2k/file-system is through Composer.
composer require stk2k/file-system
After installing, you need to require Composer's autoloader:
require 'vendor/autoload.php';
License
This library is licensed under the MIT license.
Author
Disclaimer
This software is no warranty.
We are not responsible for any results caused by the use of this software.
Please use the responsibility of the your self.