PHPackages                             rumd3x/php-ftp - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [File &amp; Storage](/categories/file-storage)
4. /
5. rumd3x/php-ftp

ActiveLibrary[File &amp; Storage](/categories/file-storage)

rumd3x/php-ftp
==============

A Nice and easy to use PHP utility for handling Files over FTP.

0.1.2(4y ago)21842[1 issues](https://github.com/rumd3x/php-ftp/issues)MITPHPPHP &gt;=5.5

Since Dec 2Pushed 4y agoCompare

[ Source](https://github.com/rumd3x/php-ftp)[ Packagist](https://packagist.org/packages/rumd3x/php-ftp)[ RSS](/packages/rumd3x-php-ftp/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (3)Dependencies (2)Versions (4)Used By (0)

php-ftp
=======

[](#php-ftp)

A Nice and easy to use PHP utility for handling Files over FTP.

Installation
------------

[](#installation)

To install via composer just run

```
  composer require rumd3x/php-ftp
```

Usage
-----

[](#usage)

### Connecting to Server

[](#connecting-to-server)

The constructor takes any amount of arguments, in any order. It will identify automatically the host, port and ssl specifications, but you still have to specify the username first, then the password.

If you need to, you can specify the port as an integer, the default is 21.

You can specify if the connection uses SSL or not by passing an extra argument with the string 'SSL'.

You can also not specify any args and connect later.

```
$ftp = new Rumd3x\Ftp\Ftp('host.example.com', 'user', 'pass', 21);
$conn1 = $ftp->isConnected();

print_r($conn1); // Returns a boolean;

//or

$ftp2 = new Rumd3x\Ftp\Ftp();
$conn2 = $ftp2->setHost('192.168.1.123')->setSecure()->setPort(666)->connect()
->setUser('test')->setPass('secret')->login()->isConnected();

print_r($conn2); // Returns a boolean;

// or

$ftp3 = new Rumd3x\Ftp\Ftp(21, 'ssl', 'user', 'pass', 'host.example.com');
$conn3 = $ftp3->isConnected();

print_r($conn3); // Returns a boolean;
```

### Other FTP Commands

[](#other-ftp-commands)

To keep the connection alive

```
$ftp = new Rumd3x\Ftp\Ftp('host.example.com', 'user', 'pass', 21);
$ftp->keepAlive(); // Sends NOOP to the server to keep the connection alive

$return = $ftp->executeRaw("NOOP"); // Allows you to send a arbitrary commands to the server

print_r($return); // Outputs a object with the response data
```

To list everything in the current directory, simply:

```
$files = $ftp->getAll();
// Returns an array of mixed Directories and Files as instances of FtpFolder and FtpFile respectively
// All directories comes first, then all the files
```

### Handling directories

[](#handling-directories)

You can navigate through folders and create new folders using methods built-in the connection.

```
$dir = $ftp->currentFolder(); // gets the current folder directory you are in on the server
// $dir has "/"

$dir = $ftp->createFolder('test/example/123')->dir('test')->dir('example/123')->currentFolder();
// $dir now has "/test/example/123"

$dir = $ftp->up()->up()->currentFolder();
// $dir now has "/test"
```

To get the list of folders on your current directory:

```
$ftp = new Rumd3x\Ftp\Ftp('host.example.com', 'user', 'pass', 21);
$folders = $ftp->getFolders(); // Outputs an array of Rumd3x\Ftp\FtpFolder
```

Or to get the FtpFolder instance of a specific folder by its name:

```
$folder = $ftp->getFolder('test');
// Outputs an instance of Rumd3x\Ftp\FtpFolder in case the folder with name 'test' exists in the current directory

$folder_name = $folder->name; // name property of FtpFolder
$folder_full_name = $folder->full_name; // full_name property of FtpFolder
$folder_timestamp = $folder->timestamp; // timestamp property of FtpFolder
$folder_permission = $folder->permission; // permission property of FtpFolder
```

#### Creating and Deleting Directories

[](#creating-and-deleting-directories)

You can also navigate through folders, create and delete using the FtpFolder Object.

```
//Connect to the FTP Server
$ftp = new Rumd3x\Ftp\Ftp('host.example.com', 'user', 'pass', 21);

//Create the folder 'FolderName' on your current dir
$folder = new Rumd3x\Ftp\FtpFolder($ftp, 'FolderName');

$folder->create()->navigateTo(); // creates the folder and navigates to it
$ftp->up(); // navigates one level up
$folder->delete(); // deletes the folder from the server
```

### Handling files

[](#handling-files)

To get the list of files on your current directory:

```
$ftp = new Rumd3x\Ftp\Ftp('host.example.com', 'user', 'pass', 21);
$folders = $ftp->getFiles(); // Outputs an array of Rumd3x\Ftp\FtpFile
```

Or to get the FtpFile instance of a specific file by its name:

```
// Outputs an instance of Rumd3x\Ftp\FtpFile in case the folder with name 'file.txt' exists in the current directory
$file = $ftp->getFolder('file.txt');

// File properties
$file_name = $file->name; // name property of FtpFile
$file_full_name = $file->full_name; // full_name property of FtpFile
$file_timestamp = $file->timestamp; // timestamp property of FtpFile
$file_permission = $file->permission; // permission property of FtpFile
```

To read the contents of a file on the server simply

```
$file->getContents(); // Returns a string with the file contents
```

To remove a file from the server simply

```
$file->delete(); // Returns a boolean with the success flag
```

#### Downloading Files

[](#downloading-files)

To download a file on the server simply

```
$local_file = '/tmp/file.txt';
$file->download($local_file); // Will download the file to the local file path
```

For large files you can also make async downloads by passing a second parameter

```
$local_file = '/tmp/file.txt';
$file->download($local_file, true); // Will download the file asynchronously to the local file path
```

You can also pass a callback to be executed on the download completion.

```
$local_file = '/tmp/file.txt';

// Will also download the file asynchronously to the local file path
$file->download($local_file, function($status) {
  if ($status === FTP_FINISHED) {
    echo 'Download success.';
  } elseif ($status === FTP_FAILED) {
    echo 'Download failed.';
  } else {
    echo 'Something else happened.';
  }
});
```

#### Editing Files

[](#editing-files)

```
$contents = 'new file contents';
$file->setContents($contents);
$file->upload();
```

#### Creating new Files

[](#creating-new-files)

```
$ftp = new Rumd3x\Ftp\Ftp('host.example.com', 'user', 'pass', 21);

$local_file = '/etc/file.txt';
$contents = file_get_contents($local_file);

//Create the file 'file.txt' on your current dir
$file = new Rumd3x\Ftp\FtpFile($ftp, 'file.txt');
$file->setContents($contents);
$file->upload();
```

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance10

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity48

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 92.1% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~592 days

Total

3

Last Release

1535d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/3a9bb5384975b87cebcef2b7642e2b5b3b79d0a3be614fdcbbe008f5b6ca3c08?d=identicon)[edmur](/maintainers/edmur)

---

Top Contributors

[![rumd3x](https://avatars.githubusercontent.com/u/12579932?v=4)](https://github.com/rumd3x "rumd3x (58 commits)")[![pherrymason](https://avatars.githubusercontent.com/u/1103977?v=4)](https://github.com/pherrymason "pherrymason (5 commits)")

---

Tags

clientcomposerftpphpphpftpclientphp ftprumd3x

### Embed Badge

![Health badge](/badges/rumd3x-php-ftp/health.svg)

```
[![Health](https://phpackages.com/badges/rumd3x-php-ftp/health.svg)](https://phpackages.com/packages/rumd3x-php-ftp)
```

###  Alternatives

[league/flysystem

File storage abstraction for PHP

13.6k639.1M2.2k](/packages/league-flysystem)[blueimp/jquery-file-upload

File Upload widget for jQuery.

141.5M18](/packages/blueimp-jquery-file-upload)[jacekbarecki/flysystem-onedrive

OneDrive adapter for the flysystem filesystem abstraction library

2429.9k](/packages/jacekbarecki-flysystem-onedrive)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
