sf2h / sftp-bundle
此包已被废弃,不再维护。未建议替代包。
此包提供与 SFTP 服务器交互的简单功能
v1.1
2020-12-20 23:14 UTC
Requires
- php: ^7
- ext-ssh2: *
- symfony/symfony: >=3.0
Requires (Dev)
- phpspec/phpspec: *
- phpunit/phpunit: ~5.0
This package is auto-updated.
Last update: 2021-10-10 11:41:51 UTC
README
SFTP Bundle
此包提供了一个简单的接口,用于通过 SFTP 协议传输文件。
安装
- 使用 Composer 安装包
composer require nw/sftp-bundle
- 在
AppKernel.php
中启用包
class AppKernel extends Kernel { public function registerBundles() { return array( // ... other bundles new NW\SFTPBundle\NWSFTPBundle() ); } }
使用方法
- 连接到 SFTP 服务器
$sftp = $this->get('nw.sftp'); $sftp->connect($host, $port); $sftp->login($username, $password); // or $sftp->loginWithKey($host, $username, $pubkeyfile, $privkeyfile, $passphrase = null);
- 使用 SFTP 客户端传输文件
$sftp->fetch('/path/to/remoteFile', '/path/to/localFile'); // or $sftp->send('/path/to/localFile', '/path/to/remoteFile');
- 从 CLI 可以使用以下命令之一
app/console nw:sftp:fetch /path/to/remoteFile /path/to/localFile # - copy files from a remote server to the local machine # or app/console nw:sftp:send /path/to/localFile /path/to/remoteFile # - copy files from a local machine to the remote server