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

ActiveLibrary

axguowen/ftp-client
===================

Simple PHP FTP Client Library

v1.0.1(1y ago)016Apache-2.0PHPPHP &gt;=7.2.5

Since Jan 2Pushed 1y ago1 watchersCompare

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

READMEChangelog (2)DependenciesVersions (3)Used By (0)

PHP FTP 客户端管理器
==============

[](#php-ftp-客户端管理器)

一个简单的 PHP FTP 客户端连接管理工具

特性
--

[](#特性)

- 支持断线重连
- 支持单例模式
- 支持动态切换连接
- 支持设置根目录

安装
--

[](#安装)

```
composer require axguowen/ftp-client

```

使用
--

[](#使用)

### 配置连接

[](#配置连接)

```
use \axguowen\facade\FtpClient;

// FTP服务器配置信息设置（全局有效）
FtpClient::setConfig([
    // 默认连接本机
    'default' => 'localhost',
    // 临时文件目录
    'temp_dir' => '',
    // 连接配置
    'connections' => [
        // 本机连接参数
        'localhost' => [
            // 主机
            'host'              => '127.0.0.1',
            // 端口
            'port'              => 21,
            // 用户名
            'username'          => '',
            // 密码
            'password'          => '',
            // 被动模式
            'passive'           => false,
            // 根目录
            'root_path'         => '',
            // 超时时间
            'timeout'           => 5,
            // 是否需要断线重连
            'break_reconnect'   => false,
            // 断线重连标识
            'break_match_str'   => [],
        ],
        // 其它主机连接参数
        'other' => [
            // 主机
            'host'      => '192.168.0.2',
            // 端口
            'port'      => 21,
            // 用户名
            'username'  => '',
            // 密码
            'password'  => '',
            // 超时时间
            'timeout'   => 5
        ],
    ]
]);
```

### 简单使用

[](#简单使用)

```
use \axguowen\facade\FtpClient;
// 传送指定内容到文件
$putObjectResult = FtpClient::putObject('/test/myfile.txt', 'file content');
// 成功
if(!is_null($putObjectResult[0])){
    echo '上传成功';
}else{
    echo $putObjectResult[1]->getMessage();
}
```

### 切换连接其它主机

[](#切换连接其它主机)

```
use \axguowen\facade\FtpClient;
// 连接其它服务器
$ftpClientOther = FtpClient::connect('other');
// 传送指定内容到文件
$putObjectResult = $ftpClientOther->putObject('/test/myfile.txt', 'file content');
// 成功
if(!is_null($putObjectResult[0])){
    echo '上传成功';
}else{
    echo $putObjectResult[1]->getMessage();
}
```

### 动态传入连接的主机参数

[](#动态传入连接的主机参数)

```
use \axguowen\facade\FtpClient;
// 动态连接
$ftpClient = FtpClient::connect([
    // 主机
    'host' => 'xx.xx.xx.xx',
    // 端口
    'port' => 21,
    // 用户名
    'username' => 'username',
    // 密码
    'password' => 'password',
]);
// 传送指定内容到文件
$putObjectResult = $ftpClient->putObject('/test/myfile.txt', 'file content');
// 成功
if(!is_null($putObjectResult[0])){
    echo '上传成功';
}else{
    echo $putObjectResult[1]->getMessage();
}
```

### 其它方法

[](#其它方法)

```
use \axguowen\facade\FtpClient;
// 传送指定内容到指定文件
$putObjectResult = FtpClient::putObject('/test/myfile.txt', 'file content');
// 上传本地文件到指定文件
$putFileResult = FtpClient::putFile('/test/myfile.txt', '/test/localfile.txt');
// 删除FTP上的文件
$deleteFileResult = FtpClient::deleteFile('/test/myfile.txt');
// 删除FTP上的目录
$deleteDirResult = FtpClient::deleteDir('/test/mydir');
// 重命名FTP上的文件
$renameFileResult = FtpClient::renameFile('/test/oldfilename.txt', '/test/newfilename.txt');
// 重命名FTP上的目录
$renameDirResult = FtpClient::renameDir('/test/olddirname', '/test/newdirname');
// 返回指定文件大小, 第二个参数传入单位, 支持b, kb, mb, gb;
$fileSizeResult = FtpClient::fileSize('/test/myfile.txt', 'kb');
// 返回文件最后修改时间, 第二个参数传入格式, 不传默认返回时间戳;
$fileUpdateTimeResult = FtpClient::fileUpdateTime('/test/myfile.txt', 'Y-m-d H:i:s');
// 返回指定目录下的文件列表
$fileListResult = FtpClient::fileList('/test/mydir');
```

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance37

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.

###  Release Activity

Cadence

Every ~292 days

Total

2

Last Release

566d ago

### Community

Maintainers

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

---

Top Contributors

[![axguowen](https://avatars.githubusercontent.com/u/61955804?v=4)](https://github.com/axguowen "axguowen (7 commits)")

---

Tags

phpftpclient

### Embed Badge

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

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

###  Alternatives

[deepseek-php/deepseek-php-client

deepseek PHP client is a robust and community-driven PHP client library for seamless integration with the Deepseek API, offering efficient access to advanced AI and data processing capabilities.

47073.9k5](/packages/deepseek-php-deepseek-php-client)[ebics-api/ebics-client-php

PHP library to communicate with bank through EBICS protocol.

6411.1k](/packages/ebics-api-ebics-client-php)[automattic/wistia-php

PHP wrapper for Wistia API

1431.9k](/packages/automattic-wistia-php)

PHPackages © 2026

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