PHPackages                             pecee/ftp-client - 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. pecee/ftp-client

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

pecee/ftp-client
================

A flexible FTP and SSL-FTP client for PHP. This lib provides helpers easy to use to manage the remote files.

1.1.1(10y ago)1294MITPHPPHP &gt;=5.4

Since Apr 26Pushed 9y ago1 watchersCompare

[ Source](https://github.com/skipperbent/ftp-client)[ Packagist](https://packagist.org/packages/pecee/ftp-client)[ Docs](https://github.com/Nicolab/php-ftp-client)[ RSS](/packages/pecee-ftp-client/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (2)Dependencies (1)Versions (5)Used By (0)

pecee/ftp-client
================

[](#peceeftp-client)

A flexible FTP and SSL-FTP client for PHP. This lib provides helpers easy to use to manage the remote files.

Install
-------

[](#install)

` composer require pecee/ftp-client`

Getting Started
---------------

[](#getting-started)

Connect to a server FTP :

```
$ftp = new \FtpClient\FtpClient();
$ftp->connect($host, $sslEnabled, $port);
$ftp->login($login, $password);
```

Note: The connection is implicitly closed at the end of script execution (when the object is destroyed). Therefore it is unnecessary to call `$ftp->close()`, except for an explicit re-connection.

### Usage

[](#usage)

Upload all files and all directories is easy:

```
// upload with the BINARY mode
$ftp->uploadDirectory($sourceDirectory, $targetDirectory);

// Is equal to
$ftp->uploadDirectory($sourceDirectory, $targetDirectory, FTP_BINARY);

// or upload with the ASCII mode
$ftp->uploadDirectory($sourceDirectory, $targetDirectory, FTP_ASCII);
```

*Note : `FTP_ASCII` and `FTP_BINARY` are predefined PHP internal constants.*

Get a directory size:

```
// size of the current directory
$size = $ftp->getDirectorySize();

// size of a given directory
$size = $ftp->getDirectorySize('/path/of/directory');
```

Count the items in a directory:

```
// count in the current directory
$total = $ftp->count();

// count in a given directory
$total = $ftp->count('/path/of/directory');

// count only the "files" in the current directory
$total_file = $ftp->count('.', 'file');

// count only the "files" in a given directory
$total_file = $ftp->count('/path/of/directory', 'file');

// count only the "directories" in a given directory
$total_dir = $ftp->count('/path/of/directory', 'directory');

// count only the "symbolic links" in a given directory
$total_link = $ftp->count('/path/of/directory', 'link');
```

Detailed list of all files and directories:

```
// scan the current directory and returns the details of each item
$items = $ftp->scanDirectory();

// scan the current directory (recursive) and returns the details of each item
var_dump($ftp->scanDirectory('.', true));
```

Result:

```
'directory#www' =>
    array (size=10)
      'permissions' => string 'drwx---r-x' (length=10)
      'number'      => string '3' (length=1)
      'owner'       => string '32385' (length=5)
      'group'       => string 'users' (length=5)
      'size'        => string '5' (length=1)
      'month'       => string 'Nov' (length=3)
      'day'         => string '24' (length=2)
      'time'        => string '17:25' (length=5)
      'name'        => string 'www' (length=3)
      'type'        => string 'directory' (length=9)

  'link#www/index.html' =>
    array (size=11)
      'permissions' => string 'lrwxrwxrwx' (length=10)
      'number'      => string '1' (length=1)
      'owner'       => string '0' (length=1)
      'group'       => string 'users' (length=5)
      'size'        => string '38' (length=2)
      'month'       => string 'Nov' (length=3)
      'day'         => string '16' (length=2)
      'time'        => string '14:57' (length=5)
      'name'        => string 'index.html' (length=10)
      'type'        => string 'link' (length=4)
      'target'      => string '/var/www/shared/index.html' (length=26)

'file#www/README' =>
    array (size=10)
      'permissions' => string '-rw----r--' (length=10)
      'number'      => string '1' (length=1)
      'owner'       => string '32385' (length=5)
      'group'       => string 'users' (length=5)
      'size'        => string '0' (length=1)
      'month'       => string 'Nov' (length=3)
      'day'         => string '24' (length=2)
      'time'        => string '17:25' (length=5)
      'name'        => string 'README' (length=6)
      'type'        => string 'file' (length=4)

```

All FTP PHP functions are supported and some improved :

```
// Requests execution of a command on the FTP server
$ftp->exec($command);

// Turns passive mode on or off
$ftp->pasv(true);

// Set permissions on a file via FTP
$ftp->chmod('0777', 'file.php');

// Removes a directory
$ftp->deleteFile('path/of/directory/to/remove');

// Removes a directory (recursive)
$ftp->deleteDirectory('path/of/directory/to/remove', true);

// Creates a directory
$ftp->createDirectory('path/of/directory/to/create');

// Creates a directory (recursive),
// creates automaticaly the sub directory if not exist
$ftp->createDirectory('path/of/directory/to/create', true);

// and more ...
```

Get the help information of remote FTP server:

```
var_dump($ftp->help());
```

Result :

```
array (size=6)
  0 => string '214-The following SITE commands are recognized' (length=46)
  1 => string ' ALIAS' (length=6)
  2 => string ' CHMOD' (length=6)
  3 => string ' IDLE' (length=5)
  4 => string ' UTIME' (length=6)
  5 => string '214 Pure-FTPd - http://pureftpd.org/' (length=36)

```

*Note : The result depend of FTP server.*

### Extendable

[](#extendable)

Create your custom `FtpClient`.

```
// MyFtpClient.php

/**
 * My custom FTP Client
 * @inheritDoc
 */
class MyFtpClient extends \FtpClient\FtpClient {

  public function removeByTime($path, $timestamp) {
      // your code here
  }

  public function search($regex) {
      // your code here
  }
}
```

```
// example.php
$ftp = new MyFtpClient();
$ftp->connect($host);
$ftp->login($login, $password);

// remove the old files
$ftp->removeByTime('/www/mysite.com/demo', time() - 86400));

// search PNG files
$ftp->search('/(.*)\.png$/i');
```

Testing
-------

[](#testing)

Using PHPUnit tests

License
-------

[](#license)

MIT (c) 2016.

Based on code by Nicolab
------------------------

[](#based-on-code-by--nicolab)

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity61

Established project with proven stability

 Bus Factor1

Top contributor holds 100% 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 ~0 days

Total

3

Last Release

3670d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/2dab716ac4ac16ea3e01400efe43853b43821b33b8c601c2c772689d58cebf3c?d=identicon)[sessingo](/maintainers/sessingo)

---

Top Contributors

[![skipperbent](https://avatars.githubusercontent.com/u/634762?v=4)](https://github.com/skipperbent "skipperbent (12 commits)")

---

Tags

ftphelpersftpserverfilessllibssl-ftp

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/pecee-ftp-client/health.svg)

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

###  Alternatives

[nicolab/php-ftp-client

A flexible FTP and SSL-FTP client for PHP. This lib provides helpers easy to use to manage the remote files.

6435.3M24](/packages/nicolab-php-ftp-client)[yii2mod/yii2-ftp

A flexible FTP and SSL-FTP client for PHP. This lib provides helpers easy to use to manage the remote files.

32433.0k3](/packages/yii2mod-yii2-ftp)[league/flysystem

File storage abstraction for PHP

13.6k639.1M2.2k](/packages/league-flysystem)[creocoder/yii2-flysystem

The flysystem extension for the Yii framework

2931.7M62](/packages/creocoder-yii2-flysystem)[league/flysystem-sftp-v3

SFTP filesystem adapter for Flysystem.

6129.6M91](/packages/league-flysystem-sftp-v3)[league/flysystem-ftp

FTP filesystem adapter for Flysystem.

2820.8M101](/packages/league-flysystem-ftp)

PHPackages © 2026

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