PHP code example of bayfrontmedia / multi-filesystem

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

    

bayfrontmedia / multi-filesystem example snippets


use Bayfront\MultiFilesystem\Disk;
use Bayfront\MultiFilesystem\DiskName;
use League\Flysystem\Local\LocalFilesystemAdapter;
use League\Flysystem\Filesystem;

$local_adapter = new LocalFilesystemAdapter(__DIR__.'/root/directory/');
$local = new Filesystem($local_adapter);

$disk = new Disk(DiskName::LOCAL, $local);

use Aws\S3\S3Client;
use Bayfront\MultiFilesystem\DiskName;
use League\Flysystem\AwsS3V3\AwsS3V3Adapter;
use League\Flysystem\Filesystem;

$s3_client = new S3Client([ // Example connecting to Linode object storage
    'version' => 'latest',
    'region' => 'us-southeast-1',
    'endpoint' => 'https://us-southeast-1.linodeobjects.com',
    'credentials' =>
        [
            'key' => 'LINODE_ACCESS_KEY',
            'secret' => 'LINODE_SECRET_KEY',
        ],
]);

$bucket_name = 'NAME_OF_BUCKET';
$path_prefix = 'path/to/storage'; // No leading slash

$s3_adapter = new AwsS3V3Adapter($s3_client, $bucket_name, $path_prefix);
$s3 = new Filesystem($s3_adapter);

$disk->add(DiskName::AWS_S3, $s3);