sftp Extension for SFTP

  1. Requirements
  2. Usage

Simple extension for managing SFTP functions.

Requirements

Yii 1.1 or above

Usage

  1. Put extracted sftp folder to extension directory.
  2. Below code snaps shows how to setup and use it with yii environment.
'import'=>array(
		'application.extensions.sftp.*',
)

'components'=>array(
	'sftp'=>array(
		'class'=>'SftpComponent',
		'host'=>'127.0.0.1',
		'port'=>22,
		'username'=>'test',
		'password'=>'test.1',
	),
),


//example 1

try
{
	// Listing files
	Yii::app()->sftp->connect();
	$cur_dir = Yii::app()->sftp->getCurrentDir() . '/';
	$files = Yii::app()->sftp->listFiles($cur_dir);
}
catch(Exception $e)
{
	echo $e->getMessage();
}	

//example 2
try
{
	$sftp_obj = new SftpComponent('127.0.0.1', 'test', 'test.1');
	$sftp_obj->connect();
	$cur_dir = $sftp_obj->getCurrentDir() . '/';
	$files = $sftp_obj->listFiles($cur_dir);
}
catch(Exception $e)
{
	echo $e->getMessage();
}

// Available methods
$sftp_obj->chdir()              // Change directory
$sftp_obj->chmod()              // Change permission
$sftp_obj->chown()              // Change ownership
$sftp_obj->createDirectory()    // Create directory on remote location
$sftp_obj->execCmd()            // Execute os commands
$sftp_obj->getAtime()           // Get file created date/time
$sftp_obj->getCurrentDir()      // Get current directory path
$sftp_obj->getFile()            // Retrieve file from remote location
$sftp_obj->getMdtm()            // Get file modified date/time
$sftp_obj->getSize()            // Get file size
$sftp_obj->isDir()              // Check for directory
$sftp_obj->listFiles()          // List directory content
$sftp_obj->removeDirectory()    // Remove directory on remote location
$sftp_obj->removeFile()         // Remove file
$sftp_obj->sendFile()           // Send file to remote location
5 1
10 followers
1 822 downloads
Yii Version: 1.1
License: BSD-2-Clause
Category: Networking
Developed by: Aruna Attanayake
Created on: Oct 15, 2011
Last updated: 13 years ago

Downloads

show all

Related Extensions