定制 thadbryson/flysystem-fallback 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

thadbryson/flysystem-fallback

Composer 安装命令:

composer require thadbryson/flysystem-fallback

包简介

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

README 文档

README

Installation

Use Composer:

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

This is a plugin for the Flysystem project. https://github.com/thephpleague/flysystem

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.

Here is some example code to set everything up.

Primary

The $primary Filesystem is the main one. It gets checked 1st.

Fallbacks

The $fallback Filesystems are ones checked after $primary. They go in order in their array.

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".

NOTE: all these methods return FALSE if $path is not found.

  • 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:

  • 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.

统计信息

  • 总下载量: 32
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: Unknown
  • 更新时间: 2017-03-24

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固