2amigos/yii2-flysystem-component 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

2amigos/yii2-flysystem-component

最新稳定版本:1.0.0

Composer 安装命令:

composer require 2amigos/yii2-flysystem-component

包简介

The League Flysystem integration for Yii Framework

README 文档

README

Latest Stable Version Software License Build Status Quality Score Total Downloads

Flysystem is a file system abstraction which allows you to easily swap out a local filesystem for a remote one.

This component library provides components that expose the Flysystem API to your Yii 2 applications. The following are the currently supported ones:

Install

The preferred way to install this extension is through composer.

Either run

$ composer require 2amigos/yii2-flysystem-component

or add

"2amigos/yii2-flysystem-component": "^1.0" 

to the require section of your composer.json file.

Usage

AwsS3FsComponent

Install dependency

$ composer require league/flysystem-aws-s3-v3

Configure on the application components section:

return [ //... 'components' => [ //... 'fs' => [ 'class' => 'dosamigos\flysystem\AwsS3FsComponent', 'key' => 'your-key', 'secret' => 'your-secret', 'bucket' => 'your-bucket', 'region' => 'your-region', // 'version' => 'latest', // 'baseUrl' => 'your-base-url', // 'prefix' => 'your-prefix', // 'options' => [], ], ], ];

When you application run, you will be able to use the component as:

Yii::$app->fs->read(....);

Check http://flysystem.thephpleague.com/api/ for all the methods available. Same methods for all adapters.

AzureFsComponent

First ensure the pear repository is added to your composer.json file:

"repositories": [ { "type": "pear", "url": "http://pear.php.net" } ], 

Then install the latest version of the plugin

$ composer require league/flysystem-azure

Configure on the application components section:

return [ //... 'components' => [ //... 'fs' => [ 'class' => 'dosamigos\flysystem\AzureFsComponent', 'accountName' => 'your-account-name', 'accountKey' => 'your-account-key', 'container' => 'your-container', ], ], ];

DropboxFsComponent

Install dependency

$ composer require spatie/flysystem-dropbox

Configure on the application components section:

return [ //... 'components' => [ //... 'fs' => [ 'class' => 'dosamigos\flysystem\DropboxFsComponent', 'token' => 'your-access-token', // 'prefix' => 'your-prefix', ], ], ];

FtpFsComponent

Configure application components as follows

return [ //... 'components' => [ //... 'ftpFs' => [ 'class' => 'dosamigos\flysystem\FtpFsComponent', 'host' => 'ftp.example.com', // 'port' => 21, // 'username' => 'your-username', // 'password' => 'your-password', // 'ssl' => true, // 'timeout' => 60, // 'root' => '/path/to/root', // 'permPrivate' => 0700, // 'permPublic' => 0744, // 'passive' => false, // 'transferMode' => FTP_TEXT, ], ], ];

GoogleCloudFsComponent

Install dependency

$ composer require cedricziel/flysystem-gcs

Configure on the application components section:

return [ //... 'components' => [ //... 'fs' => [ 'class' => 'dosamigos\flysystem\GoogleCloudFsComponent', 'projectId' => 'your-project-id', 'bucket' => 'your-bucket', // 'prefix' => 'your-prefix', ], ], ];

GridFSFsComponent

Install dependency

$ composer require league/flysystem-gridfs

Configure on the application components section:

return [ //... 'components' => [ //... 'fs' => [ 'class' => 'dosamigos\flysystem\GridFSFsComponent', 'server' => 'mongodb://localhost:27017', 'database' => 'your-database', ], ], ];

LocalFsComponent

Configure application components as follows

return [ //... 'components' => [ //... 'fs' => [ 'class' => 'dosamigos\flysystem\LocalFsComponent', 'path' => '@webroot/your-writable-folder-to-save-files', ], ], ];

MemoryFsComponent

Install dependency

$ composer require league/flysystem-memory

Configure application components as follows

return [ //... 'components' => [ //... 'fs' => [ 'class' => 'dosamigos\flysystem\MemoryFsComponent', ], ], ];

NullFsComponent

Configure application components as follows

return [ //... 'components' => [ //... 'fs' => [ 'class' => 'dosamigos\flysystem\NullFsComponent', ], ], ];

RackspaceFsComponent

Install dependency

$ composer require league/flysystem-rackspace

Configure application components as follows

return [ //... 'components' => [ //... 'fs' => [ 'class' => 'dosamigos\flysystem\RackspaceFsComponent', 'endpoint' => 'your-endpoint', 'region' => 'your-region', 'username' => 'your-username', 'apiKey' => 'your-api-key', 'container' => 'your-container', // 'prefix' => 'your-prefix', ], ], ];

SftpFsComponent

Install dependency

$ composer require league/flysystem-sftp

Configure application components as follows

return [ //... 'components' => [ //... 'fs' => [ 'class' => 'dosamigos\flysystem\SftpFsComponent', 'host' => 'sftp.example.com', 'username' => 'your-username', 'password' => 'your-password', 'privateKey' => '/path/to/or/contents/of/privatekey', // 'port' => 22, // 'timeout' => 60, // 'root' => '/path/to/root', // 'permPrivate' => 0700, // 'permPublic' => 0744, ], ], ];

WebDAVFsComponent

Install dependency

$ composer require league/flysystem-webdav

Configure application components as follows

return [ //... 'components' => [ //... 'fs' => [ 'class' => 'dosamigos\flysystem\WebDAVFsComponent', 'baseUri' => 'your-base-uri', // 'userName' => 'your-user-name', // 'password' => 'your-password', // 'proxy' => 'your-proxy', // 'authType' => \Sabre\DAV\Client::AUTH_BASIC, // 'encoding' => \Sabre\DAV\Client::ENCODING_IDENTITY, // 'prefix' => 'your-prefix', ], ], ];

ZipArchiveFsComponent

Install dependency

$ composer require league/flysystem-ziparchive

Configure application components as follows

return [ //... 'components' => [ //... 'fs' => [ 'class' => 'dosamigos\flysystem\ZipArchiveFsComponent', 'path' => '@webroot/files/archive.zip', // 'prefix' => 'your-prefix', ], ], ];

Cool Stuff

Multiple Instances

You can configure as many components as you need. Simply add them to the components section with different names. For example, I could have S3 and FTP at the same time:

return [ //... 'components' => [ //... 's3Fs' => [ 'class' => 'dosamigos\flysystem\AwsS3FsComponent', 'key' => 'your-key', 'secret' => 'your-secret', 'bucket' => 'your-bucket', 'region' => 'your-region', // 'version' => 'latest', // 'baseUrl' => 'your-base-url', // 'prefix' => 'your-prefix', // 'options' => [], ], 'ftpFs => [  'class' => 'dosamigos\flysystem\FtpFsComponent', 'host' => 'ftp.example.com', ] ], ];

Now, I could use them like Yii::$app->s3Fs and Yii::$app->ftpFs respectively.

Caching

If you wish to add caching functionality, first we need to include the dependencies on your composer.json file:

$ composer require league/flysystem-cached-adapter

Next, configure the following attributes on your adapter:

return [ //... 'components' => [ //... 'fs' => [ //... 'cache' => 'cacheID', // 'cacheKey' => 'my-cache-key', // 'cacheDuration' => 7200, ], ], ];

Replicating

The replication facilitates transitions between adapters, allowing an application to stay functional and migrate its files from one adapter to another. The adapter takes two other adapters, a source and a replica. Every change is delegated to both adapters, while all the read operations are passed onto the source only.

To use the replication feature first install its dependencies:

$ composer require league/flysystem-replicate-adapter

Next, configure as follows:

return [ //... 'components' => [ //... 's3Fs' => [ 'class' => 'dosamigos\flysystem\AwsS3FsComponent', 'key' => 'your-key', 'secret' => 'your-secret', 'bucket' => 'your-bucket', 'region' => 'your-region', ], 'ftpFs => [  'class' => 'dosamigos\flysystem\FtpFsComponent', 'host' => 'ftp.example.com', 'replica' => 's3Fs' // we have added the ID of the replica component ] ], ];

Further Information

Testing

$ phpunit

Using code fixer

We have added a PHP code fixer to standardize our code. It includes Symfony, PSR2 and some contributors rules.

./vendor/bin/php-cs-fixer fix ./src --config .php_cs

Contributing

Please see CONTRIBUTING for details.

Credits

License

The BSD License (BSD). Please see License File for more information.

687474703a2f2f7777772e67726176617461722e636f6d2f6176617461722f35353336333339346437323934356666376564333132353536656330343165302e706e67
Custom Software | Web & Mobile Software Development
www.2amigos.us

2amigos/yii2-flysystem-component 适用场景与选型建议

2amigos/yii2-flysystem-component 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 54.54k 次下载、GitHub Stars 达 22, 最近一次更新时间为 2026 年 01 月 04 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「filesystem」 「s3」 「WebDAV」 「extension」 「aws」 「azure」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 2amigos/yii2-flysystem-component 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 2amigos/yii2-flysystem-component 我们能提供哪些服务?
定制开发 / 二次开发

基于 2amigos/yii2-flysystem-component 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 54.54k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 22
  • 点击次数: 38
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 22
  • Watchers: 7
  • Forks: 8
  • 开发语言: PHP

其他信息

  • 授权协议: BSD-3-Clause
  • 更新时间: 2026-01-04