ajenguianis/ftp-sftp-connector

Library to connect to a distant server with ftp or sftp protocol.

v1.2.0 2023-09-22 15:50 UTC

This package is auto-updated.

Last update: 2024-04-17 10:54:34 UTC


README

License Latest Release Total Downloads Latest Unstable Version PHP Version

Welcome to the PHP FTP and SFTP Client Connector Library! This library simplifies FTP and SFTP protocol operations, making it easy to manage remote files and establish distant server connections. Whether you need basic file transfers or more advanced functionality, this library has you covered.

Key Features

  • User-Friendly Assistance: This library offers easy-to-use helper functions for handling remote files and establishing distant server connections.

  • Emphasis on Simplicity and Efficiency: We've designed this package to be lightweight. It acts as a convenient layer on top of PHP's native FTP and SFTP protocol capabilities, enriched with helpful utilities.

  • Customization Options: Advanced users can personalize functionality by inheriting from one of the two classes SftpClientConnector and FtpClientConnector included in the package.

Getting Started

To get started with our library, you can install it via Composer:

     composer require ajenguianis/ftp-sftp-connector

Usage

Connexion

Connect to ftp or SFTP server:

$connector= new \AA\ServerConector\Connector();
//set protocol ftp or sftp
$connector->setProtocol('ftp');
$connector->setUp($host, $login, $password, $port);
$connector->connect();

Download file

/**
 * @param $localFile
 * @param $remoteFile
 * @param $mode
 * @return bool|string
 */
 $connector->downloadFile($localFile,$remoteFil, $mode);

Get files list

 $connector->nlist($directory,$recursive);

Get files by extension

 $connector->getByExtension($directory,$recursive,$extension);

Archive file

 $connector->archive($fileFrom, $fileTo);