2017 © Pedro Peláez
 

library flysystem-fallback

Flysystem plugin use fallback Filesystems (ex: view themes).

image

thadbryson/flysystem-fallback

Flysystem plugin use fallback Filesystems (ex: view themes).

  • Saturday, May 6, 2017
  • by thadbryson
  • Repository
  • 1 Watchers
  • 1 Stars
  • 21 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

Flysystem Fallback Plugin

Installation

Use Composer:, (*1)

"thadbryson/flysystem-fallback": "@stable"

This is a plugin for the Flysystem project. https://github.com/thephpleague/flysystem, (*2)

It allows you to create a Filesystem hierarchy. If a path isn't in one Filesystem it will go to the next one until it finds it. Or runs out of Filesystems., (*3)

Here is some example code to set everything up., (*4)

Primary

The $primary Filesystem is the main one. It gets checked 1st., (*5)

Fallbacks

The $fallback Filesystems are ones checked after $primary. They go in order in their array., (*6)

Example

use TCB\Flysystem\Fallback;
use TCB\Flysystem\FallbackPlugin;

use League\Flysystem\Filesystem;
use League\Flysystem\Adapter\Local as Adapter;

// So client #1 has their own theme.
$primary = new Filesystem(new Adapter('~/themes/client-1'));

// Let's set the fallbacks in order.
$fallbacks = [
    '1'       => new Filesystem(new Adapter('~/themes/red')),
    'default' => new Filesystem(new Adapter('~/themes/default')),
];

// Add the Plugin.
$primary->addPlugin(new FallbackPlugin());

// You can get the Fallback object from the 'getFallback()' plugin method.
$fallback = $primary->getFallback($fallbacks);

// OR - you can just create the Fallback object directly.
$fallback = new Fallback($primary, $fallbacks);

Methods you can call

These Filesystem methods are available on Fallback. The first Filesystem with the path found will return the result from that Filesystem or "hit"., (*7)

NOTE: all these methods return FALSE if $path is not found., (*8)

  • has(string $path): Do any of these Filesystems have this path?
  • read(string $path): Read file contents from first "hit".
  • readStream(string $path): Read a stream of the file contents from first "hit".

Other methods available:, (*9)

  • find(string $path): Returns the Filesystem object of the first hit.
  • findIndex(string $path): Returns index string/int of Filesystem with $path. Will return FALSE if not found.

The Versions

06/05 2017

dev-master

9999999-dev

Flysystem plugin use fallback Filesystems (ex: view themes).

  Sources   Download

The Requires

 

The Development Requires

06/05 2017

dev-develop

dev-develop

Flysystem plugin use fallback Filesystems (ex: view themes).

  Sources   Download

The Requires

 

The Development Requires

24/03 2017

v1.0.0

1.0.0.0

Flysystem plugin use fallback Filesystems (ex: view themes).

  Sources   Download

The Requires

 

The Development Requires