PHP code example of petrknap / php-filestorage

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

    

petrknap / php-filestorage example snippets




use League\Flysystem\Adapter\Local as LocalAdapter;
use PetrKnap\Php\FileStorage\FileSystem;
use PetrKnap\Php\FileStorage\Plugin\SQLiteIndexPlugin;

$fileSystem = new FileSystem(new LocalAdapter(__DIR__ . "/temp"));
SQLiteIndexPlugin::register($fileSystem, __DIR__ . "/temp/index.sqlite"); // optional

$fileSystem->write("/file.txt", null);
$fileSystem->update("/file.txt", "Hello World!");

printf("%s", $fileSystem->read("/file.txt"));

foreach ($fileSystem->listContents() as $metadata) {
    $fileSystem->delete($metadata["path"]);
}
json
{
    "etrknap/php-filestorage": "dev-master"
    }
}