dev-master
9999999-dev https://petrknap.github.io/docs/php-splitfilesystem.htmlSplit Filesystem for PHP
MIT
The Requires
- php >=5.5
- nunzion/php-expect ^1.1
- league/flysystem ^1.0
The Development Requires
by Petr Knap
Wallogit.com
2017 © Pedro Peláez
Split Filesystem for PHP
I need to use something where around 60,000 files with average size of 30kb are stored in a single directory (this is a requirement so can't simply break into sub-directories with smaller number of files)., (*1)
The files will be accessed randomly, but once created there will be no writes to the same filesystem. I'm currently using Ext3 but finding it very slow. Any suggestions?, (*2)
-- Filesystem large number of files in a single directory - bugmenot77, voretaq7, (*3)
This file storage solves this issue simply - it creates virtual layer between file system and application. Every path is converted into path which is composed from many directories which contains only small amount of sub-directories., (*4)
If you wish to store 1 000 000 files in single directory, this file storage converts paths and stores them in tree-structure. Every directory contains only small amount of directories and files (depends on configuration)., (*5)
<?php
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']);
}
Run composer require petrknap/php-splitfilesystem or merge this JSON code with your project composer.json file manually and run composer install. Instead of dev-master you can use one of released versions., (*6)
{
"require": {
"petrknap/php-splitfilesystem": "dev-master"
}
}
Or manually clone this repository via git clone https://github.com/petrknap/php-splitfilesystem.git or download this repository as ZIP and extract files into your project., (*7)
Split Filesystem for PHP
MIT