PHP code example of phpguus / flysystem-raid

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

    

phpguus / flysystem-raid example snippets


use Aws\S3\S3Client;
use League\Flysystem\Adapter\Local;
use League\Flysystem\AwsS3v3\AwsS3Adapter;
use League\Flysystem\Config;
use League\Flysystem\Filesystem;
use PHPGuus\FlysystemRaid\RaidOneAdapter;

pter = new RaidOneAdapter([
    new Filesystem(new Local('/local_files')),
    new Filesystem(new AWSS3Adapter($s3Client, 'your-bucket-name')),
]);

$this->adapter->write('myFirstFile.txt',
    'The quick brown fox jumps over the lazy dog.', new Config());

$this->adapter = new RaidOneAdapter([
    new Filesystem(new Local('/my_other_local_drive')),
    new Filesystem(new Local('/local_files')),
    new Filesystem(new AWSS3Adapter($s3Client, 'your-bucket-name')),
]);
$this->adapter->rebuildArray();

$this->adapter = new RaidOneAdapter([
    new Filesystem(new Local('/local_files')),
    new Filesystem(new AWSS3Adapter($s3Client, 'your-bucket-name')),
]);
/* Ensure that both locations have identical data */
$this->adapter->rebuildArray();

$s3Client = new S3Client([
    'credentials' => [
        'key'    => 'your-digital-ocean-key',
        'secret' => 'your-digital-ocean-secret'
    ],
    'region' => 'your-digital-ocean-region',
    'version' => 'latest|version',
]);
$this->adapter = new RaidOneAdapter([
    new Filesystem(new Local('/my_other_local_drive')),
    new Filesystem(new AWSS3Adapter($s3Client, 'your-digital-ocean-bucket-name')),
]);
$this->adapter->rebuildArray();
$this->adapter->getMetadata($filePath);