luisfertechxonn/yii2-gsftp

Ftp is a FTP extension for [YII 2 Framework](http://www.yiiframework.com).

Installs: 1

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 0

Forks: 13

Type:composer

v1.0.3 2023-06-09 08:50 UTC

This package is auto-updated.

Last update: 2024-04-09 10:28:45 UTC


README

Latest Stable Version License

SFtp

SFtp is a FTP extension for YII 2 Framework based on Yii2-gftp extension.

Based on yii2-gsftp Thanks man.

Main change from the original package, this package has been prepared for make it work with local project which needs of specific versions of php, yii... etc.

Installation

The preferred way to install this extension is through composer.

Either run

php composer.phar require --prefer-dist luisfertechxonn/yii2-gsftp "*"

or add

"luisfertechxonn/yii2-gsftp": "*"

to the require section of your composer.json file.

Usage

Here is a basic usage of GFtp extension.

  • Create an FTP application component (in your Web config file)
return [
	// [...]
	'components'=>[
		// [...]
		'ftp' => [
			'class' => '\gftp\FtpComponent',
			'connectionString' => 'sftp://user:pass@host:22',
			'driverOptions' => [ 'timeout' => 120 ]
		]
	],
	// [...]
];
  • You can user either a connection string where protocol could be ftp or ftps or directly set protocol, user, pass, host and port properties :
return [
	// [...]
	'components'=>[
		// [...]
		'ftp' => [
			'class' => '\gftp\FtpComponent',
			'driverOptions' => [
				'class' => \gftp\FtpProtocol::valueOf('sftp')->driver,
				'user' => 'me@somewhere.otrb',
				'pass' => 'PassW0rd',
				'host' => 'ssh.somewhere.otrb',
				'port' => 22,
				'timeout' => 120
			]
		]
	],
	// [...]
];
  • You can user directly loading the main library:
use gftp\drivers\SftpDriver;

    /**
     * Function that will create the object with users and passwords
	 * Do not forget to control the exceptions and errors!!!!!
     */
    public function FTPClient(p)
    {
        $sftp = new SftpDriver();
        $sftp->setHost("host.host.es");
        $sftp->setUser("LuisferParra");
        $sftp->setPass("TheAmazingPassword123456");
        $sftp->connect();
        $sftp->login();
    }

Examples

You can find examples on Yii2-gftp extension site.