PHPackages                             hugsbrugs/php-sftp - 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. hugsbrugs/php-sftp

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

hugsbrugs/php-sftp
==================

PHP SFTP Utilities

1.1(5y ago)28144.5k—4.5%17[1 issues](https://github.com/hugsbrugs/php-sftp/issues)[1 PRs](https://github.com/hugsbrugs/php-sftp/pulls)1PHP

Since Mar 20Pushed 5y ago1 watchersCompare

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

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

php-sftp
========

[](#php-sftp)

PHP SFTP Utilities

If you also need FTP : [php-ftp](https://github.com/hugsbrugs/php-ftp)

Dependencies :
--------------

[](#dependencies-)

phpseclib : [Github](https://github.com/phpseclib/phpseclib) - [Documentation](https://api.phpseclib.org/master/) - [Examples](http://phpseclib.sourceforge.net/sftp/examples.html)

Install
-------

[](#install)

Install package with composer

```
composer require hugsbrugs/php-sftp

```

In your PHP code, load librairy

```
require_once __DIR__ . '/vendor/autoload.php';
use Hug\Sftp\Sftp as Sftp;
```

Usage
-----

[](#usage)

Test SFTP connection

```
Sftp::test($server, $user, $password, $port = 22, $timeout = 10);
```

Check if a file exists on SFTP Server

```
Sftp::is_file($server, $user, $password, $remote_file, $port = 22, $timeout = 10);
```

Delete a file on remote FTP server

```
Sftp::delete($server, $user, $password, $remote_file, $port = 22, $timeout = 10);
```

Recursively deletes files and folder in given directory (If remote\_path ends with a slash delete folder content otherwise delete folder itself)

```
Sftp::rmdir($server, $user, $password, $remote_path, $port = 22, $timeout = 10);
```

Recursively copy files and folders on remote SFTP server (If local\_path ends with a slash upload folder content otherwise upload folder itself)

```
Sftp::upload_dir($server, $user, $password, $local_path, $remote_path, $port = 22, $timeout = 10);
```

Download a file from remote SFTP server

```
Sftp::download($server, $user, $password, $remote_file, $local_file, $port = 22, $timeout = 10);
```

Download a directory from remote FTP server (If remote\_dir ends with a slash download folder content otherwise download folder itself)

```
Sftp::download_dir($server, $user, $password, $remote_dir, $local_dir,
$port = 22, $timeout = 10);
```

Rename a file on remote SFTP server

```
Sftp::rename($server, $user, $password, $old_file, $new_file, $port = 22, $timeout = 10);
```

Create a directory on remote SFTP server

```
Sftp::mkdir($server, $user, $password, $directory, $port = 22, $timeout = 10);
```

Create a file on remote SFTP server

```
Sftp::touch($server, $user, $password, $remote_file, $content, $port = 22, $timeout = 10);
```

Upload a file on SFTP server

```
Sftp::upload($server, $user, $password, $local_file, $remote_file = '', $port = 22, $timeout = 10);
```

List files on SFTP server

```
Sftp::scandir($server, $user, $password, $path, $port = 22, $timeout = 10);
```

Get default login SFTP directory aka pwd

```
Sftp::pwd($server, $user, $password, $port = 22, $timeout = 10);
```

Tests
-----

[](#tests)

Edit example/test.php with your FTP parameters then run

```
php example/test.php
```

To Do
-----

[](#to-do)

PHPUnit Tests

Author
------

[](#author)

Hugo Maugey [visit my website ;)](https://hugo.maugey.fr)

###  Health Score

40

—

FairBetter than 88% of packages

Maintenance19

Infrequent updates — may be unmaintained

Popularity44

Moderate usage in the ecosystem

Community17

Small or concentrated contributor base

Maturity65

Established project with proven stability

 Bus Factor1

Top contributor holds 70% 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 ~712 days

Total

3

Last Release

1923d ago

Major Versions

0.2 → 1.02017-03-21

### Community

Maintainers

![](https://www.gravatar.com/avatar/cc04033020c3e5219ac30edf7d7362952e88ea64a0de2f41b89559f849f09901?d=identicon)[hugsbrugs](/maintainers/hugsbrugs)

---

Top Contributors

[![hugsbrugs](https://avatars.githubusercontent.com/u/4385090?v=4)](https://github.com/hugsbrugs "hugsbrugs (7 commits)")[![lexo13](https://avatars.githubusercontent.com/u/11830742?v=4)](https://github.com/lexo13 "lexo13 (2 commits)")[![mbglytch](https://avatars.githubusercontent.com/u/11628834?v=4)](https://github.com/mbglytch "mbglytch (1 commits)")

### Embed Badge

![Health badge](/badges/hugsbrugs-php-sftp/health.svg)

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

###  Alternatives

[league/flysystem-sftp-v3

SFTP filesystem adapter for Flysystem.

6129.6M91](/packages/league-flysystem-sftp-v3)[superbalist/flysystem-google-storage

Flysystem adapter for Google Cloud Storage

26320.6M30](/packages/superbalist-flysystem-google-storage)

PHPackages © 2026

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