PHP code example of sacred / flysystem-lazy-migration-adapter

1. Go to this page and download the library: Download sacred/flysystem-lazy-migration-adapter 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/ */

    

sacred / flysystem-lazy-migration-adapter example snippets


use Sacred\Flysystem\LazyMigrationAdapter;
use League\Flysystem\Filesystem;
use League\Flysystem\Local\LocalFilesystemAdapter;

$oldAdapter = new LocalFilesystemAdapter('/mnt/old-storage');
$newAdapter = new LocalFilesystemAdapter('/mnt/new-storage');

$migratingAdapter = new LazyMigrationAdapter($oldAdapter, $newAdapter);
$filesystem = new Filesystem($migratingAdapter);

// The first read migrates the file to the new adapter transparently.
$contents = $filesystem->read('path/to/file.txt');