定制 laudirbispo/easy-ftp 二次开发

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

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

laudirbispo/easy-ftp

Composer 安装命令:

composer require laudirbispo/easy-ftp

包简介

A simple FTP Client class

关键字:

README 文档

README

A simple Easy FTPClient class

I have always chosen to build simple classes and closer to the actual use. This class represents exactly that, simple and functional.

Installation

Install the latest version with

$ composer require laudirbispo/easy-ftp

Basic Usage

<?php

  use laudirbispo\EasyFTP\FTPClient;
  use laudirbispo\EasyFTP\Exceptions\{FTPException, NoConnection};

    $FTP = new FTPClient();
    $FTP->connect(string $host, int $port, int $timeout, bool $ssl);
    // or
    $FTP->sslConnection(string $host, int $port, int $timeout);
    $FTP->login(string $user, string $pass);
    
    /**
     * Turns on or off passive mode. 
     * In passive mode, data connections are initiated by the client, rather than by the server.
     * @return bool
     */
    $FTP->passiveModeOn();
    $FTP->passiveModeOff();
    
    /**
     * Get current directory
     * @return string|null
     */
     $FTP->getCurrentDir();
     
    /**
     * Moves to the specified directory
     * @return bool
     */
     $FTP->goToDir($upUdir);
     
    /**
     * Back to the above directory
     * @return bool
     */
     $FTP->backDir();
     
    /**
     * Creates a new directory
     * @param $chmod octal - default is 0644
     * @return bool
     */
     $FTP->createDir(string $dir, 0755);
     
    /**
     * Move upload file
     * @param string $localFile
     * @param string $remoteFile
     * @param $chmod octal - default is 0644
     * @return bool
     */
     $FTP->upload(string $localFile, string $remoteFile, $chmod);
     
    /**
     * Download a file
     * @param string $remoteFile
     * @param string $localFile
     * @return bool
     */
     $FTP->download(string $remoteFile, string $localFile);
     
    /**
     * Returns the file size
     * @param string $localFile
     * @return int - 0 if it does not exist or is not a file
     */
     $FTP->getFileSize(string $remoteFile);
     
    /**
     * List directory
     * @param string $dir
     * @param bool $recursive
     * @return array
     */
     $FTP->listDir(string $dir, bool $recursive);
     
    /**
     * Rename or move file or rename folder
     * @param string $oldName
     * @param string $newName
     * @return bool
     */
     $FTP->rename(string $oldName, string $newName);
     
    /**
     * Move dir and files 
     * @param string $oldName
     * @param string $newName
     * @return bool
     */
     $FTP->move(string $oldLocal, string $newLocal);
     
    /**
     * Change chmod
     * @param string $path - file or dir
     * @param $chmod octal - default is 0644
     * @param boll $recursive - aplly to subdirectories
     * @return bool
     */
     $FTP->chmod(string $path, $chmod, bool $recursive);
     
     /**
     * Delete files and dirs
     * @param string $path - file or dir
     * @param boll $recursive - aplly to subdirectories
     * @return bool
     */
     $FTP->delete(string $path, bool $recursive);
     
    /**
     * Get the timestamp of the last modification of the file
     * @param string $file- file
     * @return int timestamp
     */
     $FTP->getLastModificationFile(string $file);
     
     /**
     * More
     * @return bool
     */
     $FTP->isDir(string $directory);
     $FTP->isFile(string $file);
     
    /**
     * Send an arbitrary command to an FTP server
     * @param string $command 
     * @return bool
     */
     $FTP->command(string $command);
     // Example
     $FTP->command("MSG Wello Word");
     
    /**
     * Send a message to server
     * @param string $message 
     * @return bool
     */
     $FTP->message(string $message);
     
    /**
     * Returns only the errors that occurred
     * @return array
     */
     $FTP->getErrors();
     
    /**
     * Checks for errors
     * @return bool
     */
     $FTP->hasErrors();
     
     /**
     * Returns a list formatted with everything that happened
     * @return html string formatted
     */
     $FTP->debug();
     
     // Debug example
    [02/05/2019 18:28:28] Status: Server connected by SSL
    [02/05/2019 18:28:28] Status: Passive mode activated
    [02/05/2019 18:28:28] Status: New directory "example", created
    [02/05/2019 18:28:28] Status: "example" chmod changed to "755"
    [02/05/2019 18:28:29] Status: "/example" deleted successfully
    [02/05/2019 18:28:29] Status: Command sent "MSG lorem ipsum dolor" executed
    [02/05/2019 18:28:29] Status: Message "Hello Word!" sent to server
    [02/05/2019 18:28:29] Status: Connection closed
    
    /**
     * Check if there is a connection
     * @return bool
     */
    $FTP->hasConnection();
    
    /**
     * End current connection
     */
    $FTP->close();
    
    /**
     * Recconect
     */
    $FTP->reconnect();

Author

Laudir Bispo - laudirbispo@outlook.com - https://twitter.com/laudir_bispo

License

Easy FTPClient is licensed under the MIT License - see the LICENSE file for details

laudirbispo/easy-ftp 适用场景与选型建议

laudirbispo/easy-ftp 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 26 次下载、GitHub Stars 达 0, 最近一次更新时间为 2019 年 02 月 05 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「ftp」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 laudirbispo/easy-ftp 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 laudirbispo/easy-ftp 我们能提供哪些服务?
定制开发 / 二次开发

基于 laudirbispo/easy-ftp 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-02-05