PHP Classes

PHP SSH2 SFTP Client: Transfer files and run commands with SFTP and SSH

Recommend this page to a friend!
  Info   View files Documentation   View files View files (2)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2020-05-18 (13 days ago) RSS 2.0 feedNot yet rated by the usersTotal: 89 This week: 13All time: 9,466 This week: 23Up
Version License PHP version Categories
php-ssh2-sftp-client 1.0.0The PHP License5Networking, PHP 5, Files and Folders
Description Author

This package can transfer files and run commands with SFTP and SSH.

It can connect to SSH server and perform operations necessary to execute file transfer operations like creating, listing, renaming and deleting directories, uploading, downloading, renaming, deleting, get status information of files, and creating symbolic links.

The package can also connect to a SSH server and execute given commands.

Name: Suxumi <contact>
Classes: 1 package by
Country: Georgia Georgia
Age: ???
All time rank: 42866 in Georgia Georgia
Week rank: 19 Up1 in Georgia Georgia Up

Details

php-ssh2-sftp-client

PHP Sftp Client Class using SSH2 functions and shell commands, with server-side error handlings

By GR admin@admin.ge

Portfolio<br> GR8cms.com

Copyright (c) 2015 GR<br> licensed under the MIT licenses<br> http://www.opensource.org/licenses/mit-license.html

USAGE

Connect to an SSH server & authenticate:
// initialize
$sftp = new \GR\SftpClient();

// connect
$sftp->connect($host, $port, $timeout);

// login
$sftp->login($user, $pass);

Get current directory:
$sftp->getCurrentDirectory();

Create directory
$sftp->createDirectory($path, $ignore_if_exists);

Delete directory
$sftp->deleteDirectory($path);

Delete file
$sftp->deleteFile($path);

Get directory content list
// just names
$sftp->getDirectoryList($path, $recursive);

// rawlist
$sftp->getDirectoryRawList($path, $recursive);

// <b>formated</b> rawlist
$sftp->getDirectoryRawListFormatted($path, $recursive);

Get file stat
$stat = $sftp->stat($path); 

Download a file
$sftp->downloadFile($remote_file, $local_file); 

Upload a file
$sftp->uploadFile($local_file, $remote_file[, int $create_mode = 0644 ] ); 

Rename file/directory
// Rename File
$sftp->renameFile($oldname, $newname);

// Rename Folder
$sftp->renameDirectory($oldname, $newname);

// both of them are alias of
$sftp->renameFileOrFolder($oldname, $newname);

Create Symlink
$sftp->createSymlink($target, $link); 

Execute custom command
$sftp->ssh2_exec($cmd); 

Close connection
$sftp->close(); 

Handle Errors

try {
	$sftp = new \GR\SftpClient();
	$sftp->connect($host, $port, $timeout);
	$sftp->login($user, $pass);
}
catch(ErrorException $e) {
	// handle the error
}

  Files folder image Files  
File Role Description
Accessible without login Plain text file README.md Doc. Documentation
Plain text file SftpClient.class.php Class Class source

 Version Control Unique User Downloads Download Rankings  
 100%
Total:89
This week:13
All time:9,466
This week:23Up

For more information send a message to info at phpclasses dot org.