PHPackages                             runtuer/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. [HTTP &amp; Networking](/categories/http)
4. /
5. runtuer/php-ftp

ActiveLibrary[HTTP &amp; Networking](/categories/http)

runtuer/php-ftp
===============

A flexible FTP and SSL-FTP client for PHP. This lib provides use native PHP API and fsockopen.

023PHP

Since Dec 26Pushed 7y ago1 watchersCompare

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

READMEChangelogDependenciesVersions (1)Used By (0)

runtuer/php-ftp
===============

[](#runtuerphp-ftp)

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

> 一个不需要php ftp扩展的FTP包.

Install
-------

[](#install)

- Use composer: *require* `runtuer/php-ftp`
- Or use GIT clone command: `git clone git@github.com:runtuer/php-ftp.git`
- Or download the library, configure your autoloader or include the 3 files of `php-ftp/src/Ftpclient` directory.

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

[](#getting-started)

Connect to a server FTP :

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

OR

Connect to a server FTP via SSL (on port 990 or another port) :

```
$ftp = new \Ftpclient();
$ftp->connect($host, true, 990);
$ftp->login($login, $password);

### Usage

Upload all files and all directories is easy :

```php
// upload with the BINARY mode
$ftp->putAll($source_directory, $target_directory);

// Is equal to
$ftp->putAll($source_directory, $target_directory, FTP_BINARY);

// or upload with the ASCII mode
$ftp->putAll($source_directory, $target_directory, FTP_ASCII);
```

*Note : .*

$ftp = new \\Ftp\\Ftpclient();

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

// size of a given directory
$size = $ftp->dirSize('/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->scanDir();

// scan the current directory (recursive) and returns the details of each item
var_dump($ftp->scanDir('.', 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->rmdir('path/of/directory/to/remove');

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

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

// Creates a directory (recursive),
// creates automaticaly the sub directory if not exist
$ftp->mkdir('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.*

### Extend

[](#extend)

Create your custom `Ftpclient`.

```
// MyFtpclient.php

/**
 * My custom FTP Client
 * @inheritDoc
 */
class MyFtpclient extends \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');
```

API doc
-------

[](#api-doc)

See the [source code](https://github.com/runtuer/php-ftp/src/Ftpclient)

Testing
-------

[](#testing)

Tested with "atoum" unit testing framework.

License
-------

[](#license)

[MIT](https://github.com/runtuer/php-ftp/LICENSE) c) 2019, Nicolas Tallefourtane.

Author
------

[](#author)

Runtuer

###  Health Score

19

—

LowBetter than 10% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity38

Early-stage or recently created project

 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/5db6bfffb6a050daf24d52e3455b3b88fd10f9fac0e570955a96f37c23499ed2?d=identicon)[runtuer](/maintainers/runtuer)

---

Top Contributors

[![runtuer](https://avatars.githubusercontent.com/u/3388426?v=4)](https://github.com/runtuer "runtuer (11 commits)")

### Embed Badge

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

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

###  Alternatives

[friendsofsymfony/rest-bundle

This Bundle provides various tools to rapidly develop RESTful API's with Symfony

2.8k73.3M319](/packages/friendsofsymfony-rest-bundle)[php-http/discovery

Finds and installs PSR-7, PSR-17, PSR-18 and HTTPlug implementations

1.3k309.5M1.2k](/packages/php-http-discovery)[nyholm/psr7

A fast PHP7 implementation of PSR-7

1.3k235.4M2.4k](/packages/nyholm-psr7)[pusher/pusher-php-server

Library for interacting with the Pusher REST API

1.5k94.8M293](/packages/pusher-pusher-php-server)[spatie/crawler

Crawl all internal links found on a website

2.8k16.3M52](/packages/spatie-crawler)[react/http

Event-driven, streaming HTTP client and server implementation for ReactPHP

78126.4M414](/packages/react-http)

PHPackages © 2026

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