PHP code example of petrknap / php-splitfilesystem

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




use League\Flysystem\Adapter\Local;
use League\Flysystem\Config;
use PetrKnap\Php\SplitFilesystem\SplitFilesystem;

$optionalConfig = new Config([
    SplitFilesystem::CONFIG_HASH_PART_LENGTH_FOR_DIRECTORIES => 3, // up to 1024 sub-nodes
    SplitFilesystem::CONFIG_HASH_PART_LENGTH_FOR_FILES => 2, // up to 256 sub-nodes
    SplitFilesystem::CONFIG_HASH_PARTS_FOR_DIRECTORIES => 1, // 1-level sub-tree
    SplitFilesystem::CONFIG_HASH_PARTS_FOR_FILES => 3, // 3-level sub-tree
]);

$fileSystem = new SplitFilesystem(new Local(__DIR__ . '/temp'), $optionalConfig);

$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-splitfilesystem": "dev-master"
    }
}