All Projects → lazzard → php-ftp-client

lazzard / php-ftp-client

Licence: MIT license
📦 Provides helper classes and methods to manage FTP files in an OOP way.

Programming Languages

PHP
23972 projects - #3 most used programming language
shell
77523 projects
Dockerfile
14818 projects

Projects that are alternatives of or similar to php-ftp-client

Aioftp
ftp client/server for asyncio (http://aioftp.readthedocs.org)
Stars: ✭ 116 (+43.21%)
Mutual labels:  ftp, ftp-client, ftp-server
FTP
FTP客户端,服务端
Stars: ✭ 34 (-58.02%)
Mutual labels:  ftp, ftp-client, ftp-server
Fluentftp
An FTP and FTPS client for .NET & .NET Standard, optimized for speed. Provides extensive FTP commands, File uploads/downloads, SSL/TLS connections, Automatic directory listing parsing, File hashing/checksums, File permissions/CHMOD, FTP proxies, FXP support, UTF-8 support, Async/await support, Powershell support and more. Written entirely in C#,…
Stars: ✭ 1,943 (+2298.77%)
Mutual labels:  ftp, ftp-client, ftps
fs2-ftp
Simple client for Ftp/Ftps/Sftp
Stars: ✭ 24 (-70.37%)
Mutual labels:  ftp, ftp-client, ftps
EOSFTPServer
A project to create a complete, standard compliant, multi-user, Objective-C (Mac OS X / iOS) FTP server.
Stars: ✭ 35 (-56.79%)
Mutual labels:  ftp, ftp-client, ftp-server
Google Drive Ftp Adapter
Google Drive FTP Adapter to connect to google drive through the FTP protocol
Stars: ✭ 292 (+260.49%)
Mutual labels:  ftp, ftp-client, ftp-server
Vscode Remote Workspace
Multi protocol support for handling remote files like local ones in Visual Studio Code.
Stars: ✭ 197 (+143.21%)
Mutual labels:  filesystem, ftp
Minimalftp
A lightweight, simple FTP server. Pure Java, no dependencies.
Stars: ✭ 94 (+16.05%)
Mutual labels:  ftp, ftp-server
Rust Ftp
FTP client for Rust
Stars: ✭ 110 (+35.8%)
Mutual labels:  ftp, ftp-client
Whipftp
OpenSource FTP / SFTP client
Stars: ✭ 158 (+95.06%)
Mutual labels:  ftp, ftp-client
Ftps
Implementation of the FTPS protocol for Golang.
Stars: ✭ 24 (-70.37%)
Mutual labels:  ftp, ftp-client
Arduinosim800l
Arduino HTTP & FTP client for SIM800L/SIM800 boards to perform GET and POST requests to a JSON API as well as FTP uploads.
Stars: ✭ 127 (+56.79%)
Mutual labels:  ftp, ftp-client
Sftpgo
Fully featured and highly configurable SFTP server with optional HTTP, FTP/S and WebDAV support - S3, Google Cloud Storage, Azure Blob
Stars: ✭ 3,534 (+4262.96%)
Mutual labels:  ftp, ftp-server
Pyftpdlib
Extremely fast and scalable Python FTP server library
Stars: ✭ 1,209 (+1392.59%)
Mutual labels:  ftp, ftp-server
Fake ftp
A fake FTP server for use with ruby tests
Stars: ✭ 77 (-4.94%)
Mutual labels:  ftp, ftp-server
Drivebackupv2
Uploads Minecraft backups to Google Drive/OneDrive or by (S)FTP
Stars: ✭ 26 (-67.9%)
Mutual labels:  ftp, ftp-client
Enchilada
Enchilada is a filesystem abstraction layer written in C#
Stars: ✭ 29 (-64.2%)
Mutual labels:  filesystem, ftp
flysystem-curlftp
Flysystem Adapter for the FTP with cURL implementation
Stars: ✭ 36 (-55.56%)
Mutual labels:  filesystem, ftp
anyfs
Portable file system for Node
Stars: ✭ 17 (-79.01%)
Mutual labels:  filesystem, ftp
Pyfilesystem2
Python's Filesystem abstraction layer
Stars: ✭ 1,256 (+1450.62%)
Mutual labels:  filesystem, ftp

Downloads Packagist Version tests Minimum PHP version License

Lazzard/FtpClient

This library provides helper classes and methods to manage your FTP files in an OOP way.

This library aimed to be a full FTP/FTPS client solution for the old (^5.5) and newer PHP releases (^8.0) that support FTP extension. (see the versions guide below)

Quick Start

composer require lazzard/php-ftp-client
<?php

require __DIR__ . '/vendor/autoload.php';

use Lazzard\FtpClient\Connection\FtpSSLConnection;
use Lazzard\FtpClient\Config\FtpConfig;
use Lazzard\FtpClient\FtpClient;

try {
    if (!extension_loaded('ftp')) {
        throw new \RuntimeException("FTP extension not loaded.");
    }

    $connection = new FtpSSLConnection('host', 'username', 'password');
    $connection->open();

    $config = new FtpConfig($connection);
    $config->setPassive(true);

    $client = new FtpClient($connection);

    print_r($client->getFeatures());

    $connection->close();

} catch (Throwable $ex) {
    print_r($ex->getMessage());
}

Usage

upload/download

// download a remote file
$client->download('path/to/remote/file', 'path/to/local/file');

// upload a local file to remote server
$client->upload('path/to/local/file', 'path/to/remote/file');

Asynchronous upload/download

// download a remote file asynchronously
$client->asyncDownload('path/to/remote/file', 'path/to/local/file', function ($state) {
    // do something every second while downloading this file
}, 1, FtpWrapper::BINARY);

// upload a remote file asynchronously
$client->asyncUpload('path/to/local/file', 'path/to/remote/file', function ($state) {
    // do something 
}, 1, FtpWrapper::BINARY);

Find more about asynchronous stuff here.

listing

// get files names within an FTP directory
$client->listDir('path/to/directory');

// get only directories
$client->listDir('path/to/directory', FtpClient::DIR_TYPE);

// get detailed information of each file within a remote directory including 
// the file path of each file
$client->listDirDetails('path/to/directory');

// recursively
$client->listDirDetails('path/to/directory', true);

copy

// copy a remote file/directory to another directory
$client->copy('path/to/remote/source', 'path/to/remote/directory');

// copy a local file/directory to the server
$client->copyFromLocal('path/to/local/file', 'path/to/remote/directory'); 

// copy a remote file/directory to local machine
$client->copyToLocal('path/to/remote/source', 'path/to/local/directory'); 

search

// get all png files within the giving directory with their details
$client->find('/.*\.png$/i', 'path/to/directory'); 

// recursively
$client->find('/.*\.png$/i', 'path/to/directory', true); 

size

// get file size
$client->fileSize('path/to/file');

// get directory size
$client->dirSize('path/to/directory');

file/directory creating

// create an FTP file
$client->createFile('path/to/file');

// create a file with content
$client->createFile('path/to/file', 'Hello world!!');

// create a remote directory
// note: this method supports recursive directory creation
$client->createDir('directory');

append

// append the giving content to a remote file
$client->appendFile('path/to/file', $content);

remove/rename

// remove an FTP file
$client->removeFile('path/to/file');

// remove an FTP directory (be careful all the files within this directory will be removed)
$client->removeDir('path/to/directory');

// rename an FTP file/directory
$client->rename('path/to/file', $newName);

move

// move an FTP file or directory to another folder
$client->move('path/to/file', 'path/to/directory');

count

// get the count of all the files within a directory
$client->getCount('path/to/directory');

// recursively
$client->getCount('path/to/directory', true);

// recursively and files only
$client->getCount('path/to/directory', true, FtpClient::FILE_TYPE);

permissions

// set a permissions on the giving FTP file/directory 
$client->setPermissions('path/to/file', [
    'owner' => 'r-w', // read & write
    'group' => 'w',
    'world' => 'w-r-e'
]);

// or you can use the UNIX file permission digits 
$client->setPermissions('path/to/file', 777);

is methods

// is an ftp directory ?
$client->isDir('path/to/file/or/directory');

// is a file type ?
$client->isFile('path/to/file/or/directory');

// is an empty file/directory ?
$client->isEmpty('path/to/file/or/directory');

// is exists on the FTP server ?
$client->isExists('path/to/file/or/directory');

// is the server support the size feature ?
$client->isFeatureSupported('SIZE');

others

// get the last modified time of the giving file (not working with directories)
$client->lastMTime('path/to/file');

// get a content of an FTP file
$client->getFileContent('path/to/file', FtpWrapper::ASCII);

// get all supported features by the FTP server
$client->getFeatures();

// get the server system
$client->getSystem();

// send a request to allocate a space of bytes for the next transfer operation
// some FTP servers requires this before transfer operations 
$client->allocateSpace(2048);

// prevent the server from closing the connection and keeping it alive
$client->keepAlive();

You can see all available methods here.

More documentation

Version Guidance

Version Status Last Release PHP Version
1.0.x EOL v1.0.2 >= 5.5
1.4.x EOL v1.4.2 >= 5.6
1.5.x EOL v1.5.3 ^7.2 | 8.0.*
1.6.x EOL v1.6.1 ^7.4 | 8.0.*
1.7.x Latest v1.7.0 ^7.4 | ^8.0

Contribution

Feel free to fork this repo if you want to enhance it or adding new features, also reported some issues that may have you facing while using the library will be very appreciated, Thank you!

They support this project

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].