PHP code example of italix / storage

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

    

italix / storage example snippets


$stored = $storage->put('tenant/' . $tenant_id, $upload_tmp_path, $_FILES['logo']['name']);

$stored->path();             // tenant/12/a3/9f2c….png   ← what to persist
$stored->sha256();
$stored->mime();              // sniffed, never what the browser claimed
$stored->original_name();     // metadata only, never a path

$form_meta->field('logo')->rules(
    Rule::mime('image/png', 'image/jpeg'),
    Rule::max_bytes(2 * 1024 * 1024),
);

$mime = MimeCatalog::defaults()
    ->with(MimeCatalog::group('audio_video'))
    ->with(['image/svg+xml' => 'svg'])       // your risk, your decision
    ->without('application/zip');

$store = new LocalStore('/data/files', null, $mime);

new HashedPath(0)                       // {folder}/{sha}.{ext}
new HashedPath(2)                       // default — {folder}/{ab}/{cd}/{sha}.{ext}
new BucketedPath(new HashedPath(1))     // {bucket}/{folder}/… — thousands of folders
new DatePath(new HashedPath(1), 'Y/m')  // {folder}/2026/08/… — archives

$file = $store->put_stream('videos', $handle, $name_c);   // constant memory

$out = $store->read_stream($file->path());
while (!feof($out)) { echo fread($out, 8192); }
fclose($out);

$stores = new StoreRegistry([
    'main'    => static fn () => new LocalStore('/data/files'),
    'archive' => static fn () => new LocalStore('/mnt/slow/files'),
], 'main');

$store = $stores->get($row['volume_c']);

$file = $store->put('uploads', $_FILES['photo']['tmp_name'], $_FILES['photo']['name']);

$url = "/media/{$file->handle_token()}/{$file->public_slug()}";
// /media/9f2c8a1b0000/summer-vacation-beach-sunset-edited.jpg
bash
php src/Libs/Italix/Storage/tests/StorageTest.php