league/flysystem-bundle
Composer 安装命令:
composer require league/flysystem-bundle
包简介
Symfony bundle integrating Flysystem into Symfony applications
README 文档
README
flysystem-bundle is a Symfony bundle integrating the Flysystem library into Symfony applications.
It provides an efficient abstraction for the filesystem in order to change the storage backend depending on the execution environment (local files in development, cloud storage in production and memory in tests).
Note: you are reading the documentation for flysystem-bundle 3.0, which relies on Flysystem 3.
If you use Flysystem 1.x, use flysystem-bundle 1.x.
If you use Flysystem 2.x, use flysystem-bundle 2.x.
Read the Upgrade guide to learn how to upgrade.
Installation
flysystem-bundle 3.x requires PHP 8.0+ and Symfony 5.4+.
If you need support for a lower PHP/Symfony version, consider using flysystem-bundle 2.x which support Flysystem 3.x and older PHP/Symfony versions.
You can install the bundle using Symfony Flex:
composer require league/flysystem-bundle
Basic usage
The default configuration file created by Symfony Flex provides enough configuration to use Flysystem in your application as soon as you install the bundle:
# config/packages/flysystem.yaml flysystem: storages: default.storage: local: directory: '%kernel.project_dir%/var/storage/default'
This configuration defines a single storage service (default.storage) based on the local adapter
and configured to use the %kernel.project_dir%/var/storage/default directory.
For each storage defined under flysystem.storages, an associated service is created using the
name you provide (in this case, a service default.storage will be created). The bundle also
creates a named alias for each of these services.
This means you can inject the storage services in your services and controllers like this:
1) Using service autowiring: typehint your service/controller argument with
FilesystemOperator and use the #[Target] attribute to select the storage by name:
use League\Flysystem\FilesystemOperator; class MyService { public function __construct( #[Target('default.storage')] private FilesystemOperator $storage, ) { } // ... }
Instead of using the #[Target] attribute, you can also typehint your service/controller
argument with FilesystemOperator and use the camelCase version of your storage
name as the variable name. However, this practice is discouraged and won't work in
future Symfony versions:
use League\Flysystem\FilesystemOperator; class MyService { private FilesystemOperator $storage; // The variable name $defaultStorage matters: it needs to be the // camelCase version of the name of your storage (foo.bar.baz -> fooBarBaz) public function __construct(FilesystemOperator $defaultStorage) { $this->storage = $defaultStorage; } // ... }
2) Using manual service registration: in your services, inject the service
that this bundle creates for each of your storages following the pattern
'flysystem.adapter.'.$storageName:
# config/services.yaml services: # ... App\MyService: arguments: $storage: @flysystem.adapter.default.storage
Once you have a FilesystemOperator, you can call methods from the Filesystem API to interact with your storage.
If you need to transfer files between the local filesystem and one of your configured storages, the bundle also provides two console commands:
bin/console flysystem:push <storage> <local-source> [remote-destination] bin/console flysystem:pull <storage> <remote-source> [local-destination]
The <storage> argument is the configured Flysystem storage name (for example default.storage), not the adapter type. When the destination is omitted, the basename of the source path is used.
Full documentation
- Getting started
- Cloud storage providers: AsyncAws S3, AWS SDK S3, Azure, Google Cloud Storage, DigitalOcean Spaces, Scaleway Object Storage
- Interacting with FTP and SFTP servers
- Using a lazy adapter to switch storage backend using an environment variable
- Creating a custom adapter
- MongoDB GridFS
- WebDAV
- BunnyCDN
Security Issues
If you discover a security vulnerability within the bundle, please follow our disclosure procedure.
Backward Compatibility promise
This library follows the same Backward Compatibility promise as the Symfony framework: https://symfony.com/doc/current/contributing/code/bc.html
Note: many classes in this bundle are either marked
@finalor@internal.@internalclasses are excluded from any Backward Compatibility promise (you should not use them in your code) whereas@finalclasses can be used but should not be extended (use composition instead).
league/flysystem-bundle 适用场景与选型建议
league/flysystem-bundle 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 32.19M 次下载、GitHub Stars 达 401, 最近一次更新时间为 2019 年 04 月 09 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「symfony」 「filesystem」 「bundle」 「Flysystem」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 league/flysystem-bundle 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 league/flysystem-bundle 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 league/flysystem-bundle 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A SDK for working with B2 cloud storage.
A PHP class providing static methods for reading, writing, copying, moving, and deleting files and directories, MIME type detection, image size detection, and file permission management
2lenet/EasyAdminPlusBundle
The bundle for easy using json-rpc api on your project
The flysystem adapter for yandex disk rest api.
Provide a way to secure accesses to all routes of an symfony application.
统计信息
- 总下载量: 32.19M
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 404
- 点击次数: 16
- 依赖项目数: 84
- 推荐数: 12
其他信息
- 授权协议: MIT
- 更新时间: 2019-04-09