kisphp/php-sftp-client

小巧的PHP SFTP客户端

0.1.0 2021-10-06 06:55 UTC

This package is not auto-updated.

Last update: 2024-09-18 18:53:23 UTC


README

example workflow

安装

在composer中添加

{
    "require": {
        "kisphp/php-sftp-client": "~0.1"
    }
}

用法

创建一个实现了 ConfigInterface 接口的配置类

<?php

use Kisphp\ConfigInterface;

class Config implements ConfigInterface
{
    public function getHost()
    {
        return '10.10.0.61';
    }
    
    public function getPort()
    {
        return 22;
    }
    
    public function getUsername()
    {
        return 'vagrant';
    }
    
    public function getPassword()
    {
        return 'vagrant';
    }
}

实例化SftpConnect类并将你的配置对象传递给它

$s = new SftpConnect(new Config());

上传文件

$s->sendFile(__DIR__ . '/source.php', 'b.php'); // will return true for success and false for failure

下载文件

$s->receiveFile('a.php', 'c.php'); // will return true for success and false for failure