定制 tofex/curl-ftp 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

tofex/curl-ftp

最新稳定版本:2.0.0

Composer 安装命令:

composer require tofex/curl-ftp

包简介

Tofex Curl FTP

README 文档

README

Tofex Curl FTP provides a client based on Curl.

Installation

$ composer require tofex/curl-ftp

License

Tofex Curl FTP is licensed under the MIT License - see the LICENSE file for details.

Usage

Creating a connection

$ftp = new Client();
$ftp->open([
    'host' => 'ftp.example.com',
    'user' => 'username',
    'password' => 'password',
    'port' => 990,
    'ssl' => true,
    'passive' => true,
    'timeout' => 30
]);

Alternatively you can create a connection using the connect() method

$ftp->connect($hostName, $port, $userName, $password, $useSsl, $usePassiveMode, $timeout);

Listing files

$files = $ftp->ls();

print_r($files);

produces

Array
(
    [0] => Array
        (
            [text] => file_1.zip
            [id] => /file_1.zip
        )

    [1] => Array
        (
            [text] => file_2.zip
            [id] => /file_2.zip
        )
)

Setting/changing current directory

$ftp->cd('directory/subdirectory');

Read file contents

$contents = $ftp->read('path/to/file.zip');

Write to file

$contents = 'file contents';
$ftp->write('path/to/file.txt', $contents);

Remove a file/directory

$ftp->rm('path/to/file.txt');

Catching errors

All exceptions are thrown as standard Exception classes with the following message format:

Could not handle content in path: {path} ({cURL error number})

统计信息

  • 总下载量: 1.05k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 0
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-04-21