sf2h/sftp-bundle

此包已被废弃,不再维护。未建议替代包。

此包提供与 SFTP 服务器交互的简单功能

安装数量: 71,466

依赖: 0

建议者: 0

安全: 0

星标: 3

关注者: 1

分支: 3

公开问题: 0

类型:symfony-bundle

v1.1 2020-12-20 23:14 UTC

This package is auto-updated.

Last update: 2021-10-10 11:41:51 UTC


README

SensioLabsInsight Scrutinizer Code Quality Build Status Maintainability

SFTP Bundle

此包提供了一个简单的接口,用于通过 SFTP 协议传输文件。

安装

  1. 使用 Composer 安装包
 composer require nw/sftp-bundle
  1. AppKernel.php 中启用包
class AppKernel extends Kernel
{
  public function registerBundles()
  {
      return array(
          // ... other bundles
          new NW\SFTPBundle\NWSFTPBundle()
       );
   }
}

使用方法

  1. 连接到 SFTP 服务器
   $sftp = $this->get('nw.sftp');
   $sftp->connect($host, $port);
   $sftp->login($username, $password);
   // or
   $sftp->loginWithKey($host, $username, $pubkeyfile, $privkeyfile, $passphrase = null);
  1. 使用 SFTP 客户端传输文件
    $sftp->fetch('/path/to/remoteFile', '/path/to/localFile');
    // or
    $sftp->send('/path/to/localFile', '/path/to/remoteFile');
  1. 从 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