Sftpserviceprovider

View the Project on GitHub AchrafSoltani/SftpServiceProvider

SftpServiceProvider

A Simple SFTP wrapper for Silex

Latest Stable Version Total Downloads License

Features

Requirements

Dependencies

// Installing php-ssh2
$ sudo apt-get install libssh2-php
// checking if all is good
$ php -m |grep ssh2 

Installation

$ composer require achrafsoltani/sftp-service-provider

Setup

require_once __DIR__.'/vendor/autoload.php';

use Silex\Application;
use AchrafSoltani\Provider\SftpServiceProvider;
use Silex\Provider\MonologServiceProvider;

$app = new Application();

// Monolog
$app->register(new Silex\Provider\MonologServiceProvider(), array(
    'monolog.logfile' => __DIR__.'/logs/development.log',
));

// SFTP
$app->register(new SftpServiceProvider(), array(
    'sftp.options' => array(
        'hostname' => 'domain.tld', // or IP address
        'username' => 'root',
        'password' => 'your_ssh_password',
        'port'     => '22' // optional
    )
));

// Usage

$app->run();

Usage

$dirs = $app['sftp']->list_files('/home/user/');
var_dump($dirs);
$app['sftp']->download('/home/user/source_file.ext', '/home/user/path/to/destination/downloaded.ext');