ufo-cms/file-system

This package is abandoned and no longer maintained. The author suggests using the symfony/filesystem package instead.

A set of classes for working with files.

2.0.3 2015-04-01 10:41 UTC

This package is auto-updated.

Last update: 2023-01-31 11:31:45 UTC


README

A set of classes for working with files.

Requirement

  • PHP >= 5.4

Installation

Via Composer:

require "ufo-cms/file-system": "dev-master"

Usage

use UFOFilesystem\Folder;
use UFOFilesystem\File;

Folder

Create folder
// create a new folder in the current folder
$myFolder = new Folder("MyFolder");
$myFolder->setConfigChmod(0777)->save();

// or create a new folder and subfolder
$mySubFolder = new Folder("MyFolder/MySubFolder");
$mySubFolder->setConfigChmod(0777)->save();
Rename folder
// rename a existing folder
$myFolder = new Folder("MyFolder");
$myFolder->setConfigRename("NewNameMyFolder")->save();
Remove folder
// Delete a existing folder
$myFolder = new Folder("MyFolder");
$myFolder->remove();
Get folder content
$myFolder = new Folder("MyFolder");
foreach($myFolder->ls() as $file) {
    // do something
}

File

Add content to file

Creates the file if it does not exist.

$contentForSaveToFile = "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.";

$myFile = new File("Lorem.txt");
$myFile->setContent($contentForSaveToFile)->save();
Rename a file
$myFile->setConfigRename("Lorem2.txt")->save();
Remove a file
$myFile->remove();

License

This library is available under the GPL-2.0+ license.