atellitech / flysystem-yii2
这是用于Yii2的文件系统适配器,与league/flysystem集成。但目前仅支持本地、内存和SFTP,并将支持AWS S3或其他正在开发的适配器。
1.0.0
2023-02-05 08:04 UTC
Requires
- php: >=8.0
- league/flysystem: ^3.0
- league/flysystem-memory: ^3.0
- league/flysystem-sftp-v3: ^3.0
- yiisoft/yii2: ^2.0
Requires (Dev)
- phpstan/phpstan: ^1.9
README
这是用于Yii2的文件系统适配器,与league/flysystem集成。但目前仅支持本地、内存和SFTP,并将支持AWS S3或其他正在开发的适配器。
支持
- 本地
请参阅 https://flysystem.thephpleague.com/docs/adapter/local/ - 内存
请参阅 https://flysystem.thephpleague.com/docs/adapter/in-memory/ - SFTPv3
请参阅 https://flysystem.thephpleague.com/docs/adapter/sftp-v3/ - AWS S3/异步AWS S3
请参阅 https://packagist.org.cn/packages/atellitech/flysystem-s3-yii2
开始使用
要求
- php8.0+
安装
$ /lib/path/composer require atellitech/flysystem-yii2
使用方法
本地
将组件添加到yii2项目的配置文件中
...
"components": [
"fs" => [
'class' => 'AtelliTech\\Yii2\\FlysystemAdapterLocal',
'rootPath' => '@runtime', // support alias name of Yii2 or defined in configuration,
'visibility' => [ // see https://flysystem.thephpleague.com/docs/visibility/
'file' => [
'public' => 0640,
'private' => 0604,
],
'dir' => [
'public' => 0740,
'private' => 7604,
],
],
'writeFlag' => LOCK_EX, // see https://php.ac.cn/manual/en/function.flock.php
'linkMode' => 2 // see https://github.com/thephpleague/flysystem/blob/3.x/src/Local/LocalFilesystemAdapter.php#L54
]
]
内存
将组件添加到yii2项目的配置文件中
...
"components": [
"fs" => [
'class' => 'AtelliTech\\Yii2\\FlysystemAdapterInMemory'
]
]
SFTPv3
将组件添加到yii2项目的配置文件中
...
"components": [
"fs" => [
'class' => 'AtelliTech\\Yii2\\FlysystemAdapterSftpV3',
'rootPath' => '/home/xxx',
'host' => 'xxx', // host (required)
'username' => 'xxx', // username (required)
'password' => null, // password (optional, default: null) set to null if privateKey is used
'privateKey' => null, // private key (optional, default: null) can be used instead of password, set to null if password is set
'passphrase' => null, // passphrase (optional, default: null), set to null if privateKey is not used or has no passphrase
'port' => 22, // port (optional, default: 22)
'useAgent' => false, // use agent (optional, default: false)
'timeout' => 30, // timeout (optional, default: 30)
'maxTries' => 4, // max tries (optional, default: 4)
'hostFingerprint' => null, // host fingerprint (optional, default: null),
'connectivity' => null, // connectivity checker (must be an implementation of 'League\Flysystem\PhpseclibV2\ConnectivityChecker' to check if a connection can be established (optional, omit if you don't need some special handling for setting reliable connections)
'visibility' [ // see https://flysystem.thephpleague.com/docs/visibility/
'file' => [
'public' => 0640,
'private' => 0604,
],
'dir' => [
'public' => 0740,
'private' => 7604,
],
],
]
]