nw/sftp-bundle

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

安装数: 1,469

依赖者: 0

建议者: 0

安全: 0

星标: 4

关注者: 2

分支: 3

开放问题: 1

类型:symfony-bundle

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

This package is auto-updated.

Last update: 2024-09-10 17:55:01 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