PHP code example of phpsoftbox / storage

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

    

phpsoftbox / storage example snippets


use PhpSoftBox\Storage\Storage;

$storage = new Storage([
    'default' => 'uploads',
    'disks' => [
        'uploads' => [
            'driver' => 'local',
            'rootPath' => __DIR__ . '/storage', // только абсолютный путь
            'baseUrl' => 'https://cdn.local',
        ],
    ],
]);

$contents = $storage->disk('uploads')->get('reports/hello.txt');

use PhpSoftBox\Storage\Storage;

$storage = new Storage([
    'default' => 's3',
    'disks' => [
        's3' => [
            'driver' => 's3',
            'bucket' => 'my-bucket',
            'key' => $_ENV['S3_KEY'],
            'secret' => $_ENV['S3_SECRET'],
            'endpoint' => 'https://storage.yandexcloud.net',
            'region' => 'ru-central1',
            'prefix' => 'app',
        ],
    ],
]);

$storage->disk('s3')->put('reports/hello.txt', 'Hello!');