PHP code example of darkotodoric / efficient-file-management

1. Go to this page and download the library: Download darkotodoric/efficient-file-management 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/ */

    

darkotodoric / efficient-file-management example snippets




// Define the folder path where files will be saved
$baseFolderPath = '/mnt/efficient-file-management/';

// Define allowed extensions
$allowedExtensions = ['json', 'xml', 'txt'];

// Define the division number (Maximum number of files in one folder)
$divisionNumber = 50000;

$efficientFileManagement = new EfficientFileManagement($baseFolderPath, $allowedExtensions, $divisionNumber);

// Get IDs from MySQL or other data source
$ids = [1337, 5162, 70312, 155312, 160312, 525312];

// Save content
foreach ($ids as $id) {
    $data = json_encode(['name' => 'File with ID ' . $id]);
    $efficientFileManagement->saveContent($id, 'json', $data);
}

// Get content
foreach($ids as $id){
    $data = $efficientFileManagement->getContent($id, 'json');
}

// Delete content
foreach($ids as $id){
    $data = json_encode(['name' => 'File with ID ' . $id]);
    $efficientFileManagement->deleteContent($id, 'json');
}