bepark/flysystem-fallback-to-read-only-adapter

Flystem adapter with a fallback to a read only flystem adapter

1.0.2 2017-11-30 15:04 UTC

This package is auto-updated.

Last update: 2024-03-28 17:28:31 UTC


README

Author Build Status Coverage Status Coverage Status Quality Score Software License Packagist Version Total Downloads

Description

Imagine that you need to read files from a system but when you change/delete it you need to assure that everything is still untouch on a first system and that the new version is available.

We develop it to allow us to easier manage some of non private data from development environment with prod data.

On the read only adapter you can:

  • read
  • list

On the write only adapter you can do whatever you want, as the limits is in relation with the given adapter itself.

So this adpater will not magical convert a normal adapter to read only. It's just blocking the usage of write or delete.

So when you have two adapters (A & B (the read only one)), the reading will be first made from the first one (A), if it is not found fallback to the second one (B). On write, it will first duplicate the data if not exist on the first one (A) and then write it (on A but nothing will change on B).

Strange behaviour

Some strange behaviour can appears ;) If you remove a file that exist only on the read only adapter, it will still be readable by the adapter.

Installation

composer require BePark/flysystem-fallback-to-read-only-adapter

Usage

$nonTouchableAdapter = new League\Flysystem\Adapter\AwsS3(...);
$doWhateverYouWantAdapter = new League\Flysystem\Adapter\Local(...);
$adapter = new BePark\Flysystem\ReadOnlyFallback\ReadOnlyFallbackAdapter($doWhateverYouWantAdapter, $nonTouchableAdapter);

Inspiration & similar adapters

Run the test

composer install
vendor/bin/atoum