定制 bayfrontmedia/multi-filesystem 二次开发

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

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

bayfrontmedia/multi-filesystem

最新稳定版本:v1.0.1

Composer 安装命令:

composer require bayfrontmedia/multi-filesystem

包简介

An easy-to-use library used to manage multiple Flysystem adapters from a single class.

README 文档

README

An easy-to-use library used to manage multiple Flysystem adapters from a single class.

License

This project is open source and available under the MIT License.

Author

Bayfront Media

Requirements

  • PHP ^8.0 (Tested up to 8.4)

Installation

composer require bayfrontmedia/multi-filesystem

Usage

NOTE: All exceptions thrown by Multi-Filesystem extend Bayfront\MultiFilesytstem\Exceptions\MultiFilesystemException, so you can choose to catch exceptions as narrowly or broadly as you like.

A disk name and a League\Flysystem\Filesystem instance must be passed to the constructor, and will automatically be set as the default disk.

To aid in consistency when referencing disks, the Bayfront\MultiFilesystem\DiskName class contains constants for each of the supported Flysystem adapters.

Example:

use Bayfront\MultiFilesystem\Disk;
use Bayfront\MultiFilesystem\DiskName;
use League\Flysystem\Local\LocalFilesystemAdapter;
use League\Flysystem\Filesystem;

$local_adapter = new LocalFilesystemAdapter(__DIR__.'/root/directory/');
$local = new Filesystem($local_adapter);

$disk = new Disk(DiskName::LOCAL, $local);

Public methods

getNames

Description:

Return array of disk names.

Parameters:

  • (None)

Returns:

  • (array)

getDefaultName

Description:

Return name of default disk.

Parameters:

  • (None)

Returns:

  • (string)

add

Description:

Add a League\Flysystem\Filesystem instance as a new disk.

If a disk exists with the same name, it will be overwritten.

Parameters:

  • $name (string): Name of disk
  • $filesystem (object): League\Flysystem\Filesystem object

Returns:

  • (self)

Example:

use Aws\S3\S3Client;
use Bayfront\MultiFilesystem\DiskName;
use League\Flysystem\AwsS3V3\AwsS3V3Adapter;
use League\Flysystem\Filesystem;

$s3_client = new S3Client([ // Example connecting to Linode object storage
    'version' => 'latest',
    'region' => 'us-southeast-1',
    'endpoint' => 'https://us-southeast-1.linodeobjects.com',
    'credentials' =>
        [
            'key' => 'LINODE_ACCESS_KEY',
            'secret' => 'LINODE_SECRET_KEY',
        ],
]);

$bucket_name = 'NAME_OF_BUCKET';
$path_prefix = 'path/to/storage'; // No leading slash

$s3_adapter = new AwsS3V3Adapter($s3_client, $bucket_name, $path_prefix);
$s3 = new Filesystem($s3_adapter);

$disk->add(DiskName::AWS_S3, $s3);

exists

Description:

Does disk name exist?

Parameters:

  • $disk (string)

Returns:

  • (bool)

Example:

if ($disk->exists('local')) {
    // Do something
}

get

Description:

Returns League\Flysystem\Filesystem instance for a given disk.

Parameters:

  • $disk = '' (string): Name of disk to return. If empty string, the default disk will be returned.

Returns:

  • (object): League\Flysystem\Filesystem object

Throws:

  • Bayfront\MultiFilesystem\Exceptions\DiskNotFoundException

Example:

try {

    $local_disk = $disk->get('local');

} catch (DiskNotFoundException $e) {
    die($e->getMessage());
}

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-08-15

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固