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

Flystem adapter with a fallback to a read-only flystem adapter

2.0.1 2023-08-07 21:04 UTC

This package is not auto-updated.

Last update: 2024-11-12 22:24:31 UTC


README

Description

Need to interact with files without altering the originals? Our dual-adapter system ensures safe access to data while allowing modifications in a controlled manner. This system is designed to help manage non-private data in a development environment while seamlessly integrating with production data.

Read-Only Adapter Functions:

  • Read
  • List

Write-Only Adapter Capabilities:

  • Complete flexibility in actions, with restrictions defined only by the adapter's capabilities.

Note: It's essential to understand that this adapter doesn't transform a regular adapter into a read-only version. Instead, it restricts write or delete operations.

How it Works: When you're working with two adapters, Adapter A (standard) and Adapter B (read-only):

  1. Reading: The system will first attempt to read from Adapter A. If the required data isn't located there, it will revert to Adapter B.

  2. Writing: If the data doesn't exist on Adapter A, the system will first create a copy there. Then, any modifications will be made to Adapter A, ensuring that Adapter B remains unchanged.

Installation

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

Usage

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