reaway / think-filesystem-driver-sftp
thinkphp filesystem sftp driver
v1.0.0
2025-07-02 06:09 UTC
Requires
- php: ^8.2
- league/flysystem-sftp-v3: ^3.0
- topthink/think-filesystem: ^3.0
README
安装
composer require reaway/think-filesystem-driver-sftp
用法
在config/filesystem.php添加配置
return [ 'default' => 'local', 'disks' => [ 'local' => [ 'type' => 'local', 'root' => app()->getRuntimePath() . 'storage', ], 'public' => [ 'type' => 'local', 'root' => app()->getRootPath() . 'public/storage', 'url' => '/storage', 'visibility' => 'public', ], // 添加配置 'sftp' => [ 'type' => 'sftp', 'root' => 'uploads', 'connection' => [ 'host' => '127.0.0.1', // 基于基础的身份验证设置... 'username' => 'username', 'password' => 'password', // 可选的 SFTP 设置 'port' => 22, ] ], ], ];
使用
use think\facade\Filesystem; $savename = Filesystem::disk('sftp')->putFile('topic', $file);