PHP code example of fi1a / filesystem

1. Go to this page and download the library: Download fi1a/filesystem 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/ */

    

fi1a / filesystem example snippets


use Fi1a\Filesystem\Adapters\LocalAdapter;
use Fi1a\Filesystem\Filesystem;

$adapter = new LocalAdapter(__DIR__ . '/Resources');
$filesystem = new Filesystem($adapter);

$folder = $filesystem->folder('./folder'); // Fi1a\Filesystem\FolderInterface
$folder->make();

$folder = $filesystem->factory('./folder'); // Fi1a\Filesystem\FolderInterface
$folder->isExist(); // true

$file = $filesystem->file($folder->getPath() . '/file.txt'); // Fi1a\Filesystem\FileInterface
$file->make();

$file = $filesystem->factory('/folder/file.txt'); // Fi1a\Filesystem\FileInterface
$file->isExist(); // true

use Fi1a\Filesystem\Adapters\LocalAdapter;
use Fi1a\Filesystem\Filesystem;

$adapter = new LocalAdapter(__DIR__ . '/Resources');
$filesystem = new Filesystem($adapter);

$folder = $filesystem->folder('./folder'); // Fi1a\Filesystem\FolderInterface
if (!$folder->isExist()) {
    $folder->make(); // true
}

use Fi1a\Filesystem\Adapters\LocalAdapter;
use Fi1a\Filesystem\Filesystem;

$adapter = new LocalAdapter(__DIR__ . '/Resources');
$filesystem = new Filesystem($adapter);

$file = $filesystem->file('./folder/file.txt'); // Fi1a\Filesystem\FileInterface
$file->write('file content'); // 12

use Fi1a\Filesystem\Adapters\LocalAdapter;
use Fi1a\Filesystem\Filesystem;

$adapter = new LocalAdapter(__DIR__ . '/Resources');
$filesystem = new Filesystem($adapter);