webalternatif/flysystem-dsn
最新稳定版本:v0.7.0
Composer 安装命令:
composer require webalternatif/flysystem-dsn
包简介
A set of factories to build Flysystem adapters from DSN (Data Source Name)
README 文档
README
A set of factories to build Flysystem adapters from DSN strings, like:
s3://user:pass@endpoint?region=region&bucket=bucket↓local://some/path↓sftp://user@host:port/absolute/path?private_key=secret.pem↓- and more...
Installation
$ composer require webalternatif/flysystem-dsn
Because this package does not explicitely require inner adapters, you will have to composer require them yourself in your project.
See the adapters section to know how to install them.
Usage
use Webf\Flysystem\Dsn\AdapterFactory\AwsS3AdapterFactory; use Webf\Flysystem\Dsn\AdapterFactory\FlysystemAdapterFactory; use Webf\Flysystem\Dsn\AdapterFactory\OpenStackSwiftAdapterFactory; $factory = new FlysystemAdapterFactory([ new AwsS3AdapterFactory(), new OpenStackSwiftAdapterFactory(), ]); $adapter = $factory->createAdapter($dsn);
Adapters
AWS S3
| Inner adapter | league/flysystem-aws-s3-v3 |
| Install | composer require league/flysystem-aws-s3-v3 |
| Factory class | Webf\Flysystem\Dsn\AdapterFactory\AwsS3AdapterFactory |
| DSN | s3://username:password@endpoint?region=region&bucket=bucket |
- Use
s3+http://if the endpoint does not support https. s3://is equivalent tos3+https://.usernameis the access key id.passwordis the secret access key.
Optional DSN parameters
version(default:latest)
Failover
| Inner adapter | webalternatif/flysystem-failover-bundle |
| Install | composer require webalternatif/flysystem-failover-bundle |
| Factory class | Webf\Flysystem\Dsn\AdapterFactory\FailoverAdapterFactory |
| DSN | failover(inner1:// inner2:// ...)?name=name |
- There must be at least two DSN arguments for the failover DSN function.
- The
nameparameter is used for the failover adapter's name in the failover bundle (used to identify adapters in Symfony commands). - For each inner DSN, you can specify a
time_shiftparameter (see configuration section of the failover bundle for more info). This parameter is removed from the inner DSN when it's built.
Ftp
| Inner adapter | league/flysystem-ftp |
| Install | composer require league/flysystem-ftp |
| Factory class | Webf\Flysystem\Dsn\AdapterFactory\FtpAdapterFactory |
| DSN | ftp://username:password@host:port/absolute/path |
- Port is optional and defaults to
21 - If the path contains spaces, replace each one by
%20.
Optional DSN parameters
ssl: whether to useftp_ssl_connectinstead offtp_connect(default:false)timeout: timeout for all network operations (default:90)utf8: whether to enable the UTF-8 mode or not (default:false)passive: whether to enable the passive mode or not (default:true)transfer_mode: transfer mode used forftp_fgetandftp_fputcalls (must beasciiorbinary, default:binary)system_type: system type of the ftp server (must beunixorwindows)ignore_passive_address: whether to set theFTP_USEPASVADDRESSoption to the oppositetimestamps_on_unix_listings: whether to set last modified in metadata or not for unix systems (default:false)recurse_manually: whether to recurse directories "manually" instead of using the FTP option when the$deepparameter oflistContents()is set totrue(default:false)public_file_permission: unix permission for public files (default:0644)private_file_permission: unix permission for public files (default:0600)public_dir_permission: unix permission for public files (default:0755)private_dir_permission: unix permission for public files (default:0700)default_dir_visibility: default visibility for automatically created directories (must bepublicorprivate, default:private)
In memory
| Inner adapter | league/flysystem-memory |
| Install | composer require league/flysystem-memory |
| Factory class | Webf\Flysystem\Dsn\AdapterFactory\InMemoryAdapterFactory |
| DSN | in-memory:// |
Optional DSN parameters
default_visibility: default visibility of created files and directories (must bepublicorprivate, default:public)
Lazy
This adapter allows deferring the creation of the inner adapter until it is actually used (i.e., when Flysystem's methods are called). This is useful when you don't want an adapter to be created, but you need to have it somewhere (e.g., in a service container), and the creation of the adapter is expensive (e.g., it makes a network request).
The drawback is that you have to make sure the DSN of the inner adapter is valid, otherwise an exception will be thrown at "usage" time.
| Inner adapter | Webf\Flysystem\Dsn\Adapter\LazyAdapter |
| Factory class | Webf\Flysystem\Dsn\AdapterFactory\LazyAdapterFactory |
| DSN | lazy(inner://) |
- There must be exactly one DSN argument for the lazy DSN function.
Local
| Inner adapter | Built-in with league/flysystem |
| Factory class | Webf\Flysystem\Dsn\AdapterFactory\LocalAdapterFactory |
| DSN | local://absolute_or_relative_path |
- If the path contains spaces, replace each one by
%20.
Optional DSN parameters
public_file_permission: unix permission for public files (default:0644)private_file_permission: unix permission for public files (default:0600)public_dir_permission: unix permission for public files (default:0755)private_dir_permission: unix permission for public files (default:0700)default_dir_visibility: default visibility for automatically created directories (must bepublicorprivate, default:private)
OpenStack Swift
| Inner adapter | webalternatif/flysystem-openstack-swift |
| Install | composer require webalternatif/flysystem-openstack-swift |
| Factory class | Webf\Flysystem\Dsn\AdapterFactory\OpenStackSwiftAdapterFactory |
| DSN | swift://username:password@endpoint?region=region&container=container |
- Use
swift+http://if the endpoint does not support https. swift://is equivalent toswift+https://.usernameis optional if parameteruser_idis present.temp_url_key(see below) is required to be able to generate temporary URLs.
Optional DSN parameters
user_id:auth.identity.password.user.idvalue sent to Keystone v3 APIuser_domain_id:auth.identity.password.user.domain.idvalue sent to Keystone v3 API (default:defaultifuser_idanduser_domain_nameare not defined)user_domain_name:auth.identity.password.user.domain.namevalue sent to Keystone v3 APIdomain_id:auth.scope.domain.idvalue sent to Keystone v3 APIdomain_name:auth.scope.domain.namevalue sent to Keystone v3 APIproject_id:auth.scope.project.idvalue sent to Keystone v3 APIproject_name:auth.scope.project.namevalue sent to Keystone v3 APIproject_domain_id:auth.scope.project.domain.idvalue sent to Keystone v3 APIproject_domain_name:auth.scope.project.domain.namevalue sent to Keystone v3 APItemp_url_key: secret key used to generate temporary URLs (more information here)
Prefix
| Inner adapter | league/flysystem-path-prefixing |
| Install | composer require league/flysystem-path-prefixing |
| Factory class | Webf\Flysystem\Dsn\AdapterFactory\PrefixAdapterFactory |
| DSN | prefix(inner://)?path=some/prefix/path |
- There must be exactly one DSN argument for the prefix DSN function.
- If the path contains spaces, replace each one by
%20.
ReadOnly
| Inner adapter | league/flysystem-read-only |
| Install | composer require league/flysystem-read-only |
| Factory class | Webf\Flysystem\Dsn\AdapterFactory\ReadOnlyAdapterFactory |
| DSN | readonly(inner://) |
- There must be exactly one DSN argument for the readonly DSN function.
Sftp
| Inner adapter | league/flysystem-sftp-v3 |
| Install | composer require league/flysystem-sftp-v3 |
| Factory class | Webf\Flysystem\Dsn\AdapterFactory\SftpAdapterFactory |
| DSN | sftp://username:password@host:port/absolute/path |
- The password can be empty if the
private_keyparameter is defined. - Port is optional and defaults to
22 - If the path contains spaces, replace each one by
%20.
Optional DSN parameters
private_key: absolute path of a private key file, can be used instead of passwordpassphrase: passphrase of the private keyuse_agent: whether to use ssh agent or not (default:false)timeout: request timeout in seconds (default:10)max_retries: number of connection retries before triggering an error (default:4)host_fingerprint: the host fingerprint to checkpublic_file_permission: unix permission for public files (default:0644)private_file_permission: unix permission for public files (default:0600)public_dir_permission: unix permission for public files (default:0755)private_dir_permission: unix permission for public files (default:0700)default_dir_visibility: default visibility for automatically created directories (must bepublicorprivate, default:private)
Tests
To run all tests, execute the command:
composer test This will run Psalm, PHPUnit, Infection and a PHP-CS-Fixer check, but you can run them individually like this:
composer psalm composer phpunit composer infection composer cs-check
webalternatif/flysystem-dsn 适用场景与选型建议
webalternatif/flysystem-dsn 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 8.02k 次下载、GitHub Stars 达 2, 最近一次更新时间为 2026 年 01 月 04 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「filesystem」 「storage」 「adapter」 「dsn」 「Flysystem」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 webalternatif/flysystem-dsn 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 webalternatif/flysystem-dsn 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 webalternatif/flysystem-dsn 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Adapter designed to add Framework Agnosticism for Caching within PHP Packages.
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
Small library to access Microsoft Windows Azure Blob Storage with a Service or a StreamWrapper.
flysystem cache Adapter
Virtual Filesystem Storage Adapter for Laravel
统计信息
- 总下载量: 8.02k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 22
- 依赖项目数: 2
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-01-04