damijanc/simple-ftp

Simple FTP wrapper

1.0.3 2016-09-02 11:05 UTC

This package is auto-updated.

Last update: 2020-11-09 19:56:31 UTC


README

Simple wrapper for PHP (http://php.net/manual/en/book.ftp.php) FTP

Motivation for this class was to simplify usage of FTP so instead of doing:

$conn = ftp_connect($host, $port, $timeout);
if ($conn) {
  $login_result = ftp_login($conn, $user, $password);
  if ($login_result) {
          $connected = TRUE;
  }
}

We simply do

use damijanc\FTP\Client;

$ftp = new Client($options);
$ftp->connect();

In addition we can use shell commands like:

cd  -change dir
put -upload a file
ls - list directory
get - download file

Example:

use damijanc\FTP\Client;

$options = array;
$options['server'] = 'ftp.example.com';
$options['port'] = 21;
$options['user'] = 'user';
$options['pass'] = 'password';

//connect to server
$ftp = new Client($options);
$ftp->connect();
//got to folder
$ftp->cd('Folder1');
//upload file
$ftp->put('file1.zip');
//list content
$ftp->ls();
//end session
$ftp->disconnect();

Installation:

composer require damijanc/simple-ftp

TODO:

  • add multiple file/folder upload
  • add upload/download progress display
  • fix code comments
  • ...