PHP code example of proglab / sftp-client-bundle

1. Go to this page and download the library: Download proglab/sftp-client-bundle library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

proglab / sftp-client-bundle example snippets


// config/bundles.php

return [
    // ...
    Proglab\SftpClientBundle\SftpClientBundle::class => ['all' => true],
];

use Proglab\SftpClientBundle\Service\SftpClient;
use Psr\Log\NullLogger;

$logger = new NullLogger();
$client = new SftpClient($logger);

use Proglab\SftpClientBundle\Service\SftpClient;

class Service
{
    public function __construct(private SftpClient $client)
    {
    }
}

$client->connect('username', 'password', 'host', 22);

$client->deco();

$files = $client->getRemoteListFiles('/var/www/');

$files = $client->getLocalListFiles('/var/www/');

$files = $client->upload($fileLocalPath, $fileRemotePath, $delete = true);

$files = $client->download($fileRemotePath, $fileLocalPath, $delete = true);

$files = $client->syncLocalDirToRemote($localDir, $remoteDir, $delete = true);

$files = $client->syncRemoteDirToLocal($remoteDir, $localDir, $delete = true);