kisphp/php-sftp-client

Tiny PHP SFTP client

0.1.0 2021-10-06 06:55 UTC

This package is not auto-updated.

Last update: 2024-05-15 17:23:32 UTC


README

example workflow

Installation

Add in composer:

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

Usage

Create a config class that implements 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';
    }
}

Instantiate SftpConnect class and pass your Config object to it

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

Upload a file

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

Download a file

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