PHP code example of ufo-cms / file-system

1. Go to this page and download the library: Download ufo-cms/file-system library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

ufo-cms / file-system example snippets


use UFOFilesystem\Folder;
use UFOFilesystem\File;

// 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 a existing folder
$myFolder = new Folder("MyFolder");
$myFolder->setConfigRename("NewNameMyFolder")->save();

// Delete a existing folder
$myFolder = new Folder("MyFolder");
$myFolder->remove();

$myFolder = new Folder("MyFolder");
foreach($myFolder->ls() as $file) {
    // do something
}

$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();

$myFile->setConfigRename("Lorem2.txt")->save();

$myFile->remove();