PHPackages                             yii2mod/yii2-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. yii2mod/yii2-ftp

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

yii2mod/yii2-ftp
================

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

1.1(9y ago)32433.0k↓25.9%8[2 PRs](https://github.com/yii2mod/yii2-ftp/pulls)3MITPHPPHP &gt;=5.4

Since Dec 22Pushed 2y ago2 watchersCompare

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

READMEChangelog (2)Dependencies (1)Versions (3)Used By (3)

 [ ![](https://avatars0.githubusercontent.com/u/993323) ](https://github.com/yiisoft)

FTP Client for Yii 2
====================

[](#ftp-client-for-yii-2)

[![Latest Stable Version](https://camo.githubusercontent.com/876b0157310b12ce6fcaa2c4f9433f176b7a9d69ee2121cc47718d8eb61cef4d/68747470733a2f2f706f7365722e707567782e6f72672f796969326d6f642f796969322d6674702f762f737461626c65)](https://packagist.org/packages/yii2mod/yii2-ftp) [![Total Downloads](https://camo.githubusercontent.com/c7dab7a8be70d2c14033397bc494fa5a42e1ffd6c9581106ef145b10949b792a/68747470733a2f2f706f7365722e707567782e6f72672f796969326d6f642f796969322d6674702f646f776e6c6f616473)](https://packagist.org/packages/yii2mod/yii2-ftp) [![License](https://camo.githubusercontent.com/427981d3c1455607ae67da473640eed49f8a91ad823531f808231d668d551f09/68747470733a2f2f706f7365722e707567782e6f72672f796969326d6f642f796969322d6674702f6c6963656e7365)](https://packagist.org/packages/yii2mod/yii2-ftp)

> yii2-ftp is a fork of [Nicolab/php-ftp-client](https://github.com/Nicolab/php-ftp-client) v1.2.0

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

[](#installation)

The preferred way to install this extension is through [composer](http://getcomposer.org/download/).

Either run

```
php composer.phar require --prefer-dist yii2mod/yii2-ftp "*"

```

or add

```
"yii2mod/yii2-ftp": "*"

```

to the require section of your composer.json.

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

[](#getting-started)

Connect to a server FTP :

```
$ftp = new \yii2mod\ftp\FtpClient();
$host = 'ftp.example.com';
$ftp->connect($host);
$ftp->login($login, $password);
```

OR

Connect to a server FTP via SSL (on port 22 or other port) :

```
$ftp = new \yii2mod\ftp\FtpClient();
$host = 'ftp.example.com';
$ftp->connect($host, true, 22);
$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->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\_ASCII and FTP\_BINARY are predefined PHP internal constants.*

Get a directory size :

```
// 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.*

Support us
----------

[](#support-us)

Does your business depend on our contributions? Reach out and support us on [Patreon](https://www.patreon.com/yii2mod). All pledges will be dedicated to allocating workforce on maintenance and new awesome stuff.

###  Health Score

40

—

FairBetter than 88% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity47

Moderate usage in the ecosystem

Community23

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 Bus Factor2

2 contributors hold 50%+ of commits

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 ~856 days

Total

2

Last Release

3309d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/1a53a15e1548ce60ee92591e71492a39eaaecfc88eaa1a9d7f353d5c910381de?d=identicon)[disem](/maintainers/disem)

---

Top Contributors

[![dmitry-semenov](https://avatars.githubusercontent.com/u/17027799?v=4)](https://github.com/dmitry-semenov "dmitry-semenov (4 commits)")[![morontt](https://avatars.githubusercontent.com/u/1615692?v=4)](https://github.com/morontt "morontt (4 commits)")[![BBrunekreeft](https://avatars.githubusercontent.com/u/9114578?v=4)](https://github.com/BBrunekreeft "BBrunekreeft (3 commits)")[![pozitronik](https://avatars.githubusercontent.com/u/2357892?v=4)](https://github.com/pozitronik "pozitronik (2 commits)")[![disem](https://avatars.githubusercontent.com/u/672118?v=4)](https://github.com/disem "disem (1 commits)")[![Nicolab](https://avatars.githubusercontent.com/u/1688162?v=4)](https://github.com/Nicolab "Nicolab (1 commits)")[![cpuche](https://avatars.githubusercontent.com/u/5621848?v=4)](https://github.com/cpuche "cpuche (1 commits)")

---

Tags

ftp-clientyii2yii2-ftpftphelpersftpserverfilesslyii2extensionlibssl-ftp

###  Code Quality

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/yii2mod-yii2-ftp/health.svg)

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

###  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)[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)[nemmo/yii2-attachments

Extension for file uploading and attaching to the models

6616.6k5](/packages/nemmo-yii2-attachments)

PHPackages © 2026

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