PHP code example of skyraptor / laravel-versioned-storage
1. Go to this page and download the library: Download skyraptor/laravel-versioned-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/ */
skyraptor / laravel-versioned-storage example snippets
use SkyRaptor\LaravelVersionedStorage\VersionedStorage;
$first = VersionedStorage::put('reports/daily.csv', 'first contents');
$second = VersionedStorage::put('reports/daily.csv', 'second contents');
VersionedStorage::get('reports/daily.csv'); // second contents
VersionedStorage::get('reports/daily.csv', $first); // first contents
VersionedStorage::exists('reports/daily.csv', $first);
VersionedStorage::versions('reports/daily.csv'); // [$first, $second]
use Illuminate\Filesystem\FilesystemAdapter;
use SkyRaptor\LaravelVersionedStorage\VersionedStorage;
$version = VersionedStorage::directory('reports/monthly', function (FilesystemAdapter $files): void {
$files->put('summary.txt', 'Monthly summary');
$files->put('details/data.csv', 'Monthly details');
});
$directory = VersionedStorage::directory('reports/monthly');
$directory->get('summary.txt'); // current snapshot
$directory->get('summary.txt', $version); // selected snapshot
$directory->exists('summary.txt', $version);
$directory->versions(); // oldest to newest
use Illuminate\Support\Facades\Storage;
use SkyRaptor\LaravelVersionedStorage\Testing\VersionedStorageTesting;
Storage::fake('local');
VersionedStorageTesting::runUploadsSynchronously();
config(['concurrency.default' => 'sync']); // when testing cleanup with fake disks