|
| 1 | +# :fire: FireFS |
| 2 | + |
| 3 | +Manage your file system easily, through php |
| 4 | + |
| 5 | +**FireFS** is a library allowing you to write/read/delete files and folders of your file system, safely and easily. |
| 6 | + |
| 7 | +It can be used for *web* applications as well for *console* applications, without any requirements. |
| 8 | + |
| 9 | +## Example |
| 10 | + |
| 11 | +```php |
| 12 | +<?php |
| 13 | + |
| 14 | +use ElementaryFramework\FireFS\FireFS; |
| 15 | + |
| 16 | +// Create a new file system instance at the given path |
| 17 | +$fs = new FireFS("./app"); // /root/var/www/htdocs/app/ |
| 18 | + |
| 19 | +// Check if the path "/root/var/www/htdocs/app/images/" exists |
| 20 | +if ($fs->exists("images")) { |
| 21 | + // Change the working directory to the images folder |
| 22 | + $fs->setWorkingDirectory("./images"); |
| 23 | + |
| 24 | + // Create a new file in the working directory |
| 25 | + $fs->mkfile("./logo.png"); // /root/var/www/htdocs/app/images/logo.png |
| 26 | + |
| 27 | + // Read file from the file system root path |
| 28 | + $logo = $fs->read("logo.png"); // /root/var/www/htdocs/app/logo.png |
| 29 | + |
| 30 | + // Write into the created file |
| 31 | + $fs->write("./logo.png", $logo); // /root/var/www/htdocs/app/images/logo.png |
| 32 | + |
| 33 | + // Delete the old file |
| 34 | + $fs->delete("logo.png"); // /root/var/www/htdocs/app/logo.png |
| 35 | +} |
| 36 | + |
| 37 | +// Change the working directory to the file system root path |
| 38 | +$fs->setWorkingDirectory("./"); |
| 39 | + |
| 40 | +// Create a "blog" directory |
| 41 | +$fs->mkdir("blog"); // /root/var/www/htdocs/app/blog/ |
| 42 | + |
| 43 | +// Move "images" folder from "app" to "app/blog" |
| 44 | +$fs->move("images", "blog/images"); |
| 45 | + |
| 46 | +// And more ! |
| 47 | +``` |
| 48 | + |
| 49 | +## Features |
| 50 | + |
| 51 | +- Easy file system management ; |
| 52 | +- Object Oriented file system entities management, through [Folder](https://github.com/ElementaryFramework/FireFS/blob/master/src/FireFS/Entities/Folder.php) and [File](https://github.com/ElementaryFramework/FireFS/blob/master/src/FireFS/Entities/File.php) classes ; |
| 53 | +- Receive events of what happen to your file system (created, modified, deleted events) and execute a specific action with the [file system listener](https://github.com/ElementaryFramework/FireFS/blob/master/src/FireFS/Listener/IFileSystemListener.php) ; |
| 54 | +- Run a [file system watcher](https://github.com/ElementaryFramework/FireFS/blob/master/src/FireFS/Watcher/FileSystemWatcher.php) to watch for files changes in **real time** (recommended for console applications) |
| 55 | + |
| 56 | +## Installation |
| 57 | + |
| 58 | +You can install **FireFS** in your project with [composer](http://getcomposer.org): |
| 59 | + |
| 60 | +```sh |
| 61 | +composer require elementaryframework/fire-fs |
| 62 | +``` |
| 63 | + |
| 64 | +Once installed, you can access the **FireFS** api through the `ElementaryFramework\FireFS` namespace. |
| 65 | + |
| 66 | +## How to use |
| 67 | + |
| 68 | +New to **FireFS** ? From console to web apps, you can read the [wiki](https://github.com/ElementaryFramework/FireFS/wiki) to know how to use this |
| 69 | +library into your project. |
| 70 | + |
| 71 | +## License |
| 72 | + |
| 73 | +© 2018 Aliens Group, Inc. |
| 74 | + |
| 75 | +Licensed under MIT ([read license](https://github.com/ElementaryFramework/FireFS/blob/master/LICENSE)). |
0 commit comments