File: README.md

Recommend this page to a friend!
  Classes of Suxumi  >  PHP SSH2 SFTP Client  >  README.md  >  Download  
File: README.md
Role: Documentation
Content type: text/markdown
Description: Documentation
Class: PHP SSH2 SFTP Client
Transfer files and run commands with SFTP and SSH
Author: By
Last change:
Date: 1 month ago
Size: 1,949 bytes
 

Contents

Class file image Download

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
}


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