PHP code example of nece001 / php-brawl-filesystem-local

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

    

nece001 / php-brawl-filesystem-local example snippets


    $conf = array(
        'base_path' => 'D:\Work\temp\test',
        'sub_path' => 'a/b',
        'base_url' => 'http://aaa.com',
    );

    $config = FileSystemFactory::createConfig('Local');
    $config->setConfig($conf);

    $fso = FileSystemFactory::createClient($config);
    try {

        $fso->write('c/' . time() . '.txt', 'test');
        $fso->append('c/' . time() . '.txt', 'test');

        $fso->copy('a/b/c/1687011074.txt', 'a/1.txt');
        $fso->move('a/b/a/1.txt', 'a/2.txt');
        $fso->upload('a/b/a.txt', 'a/3.txt');

        var_dump($fso->exists('a/b/c/1687011074.txt'));
        echo $fso->read('a/b/c/1687011074.txt');
        $fso->delete('a/b/a/1.txt');

        $fso->mkDir('a/d');
        echo $fso->lastModified('a/b/c/1687011074.txt');
        echo $fso->fileSize('a/b/c/1687011074.txt');
        
        print_r($fso->readDir('a/b/c/'));

        echo $fso->getUri(), '<br>';
        echo $fso->getUrl();
    } catch (Throwable $e) {
        echo $e->getMessage(), '<br>';
        echo $fso->getErrorMessage();
    }