lazzard/ftp-bridge 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

lazzard/ftp-bridge

Composer 安装命令:

composer require lazzard/ftp-bridge

包简介

Allows free communication with FTP servers according to RFC959 specification and others related RFC extensions

README 文档

README

Version Minimum PHP version tests codecov Scrutinizer Code Quality LICENSE

Lazzard/FtpBridge

Allows free communication with FTP servers according to RFC959 specification and others related RFC extensions.

Getting started

composer require lazzard/ftp-bridge:v1.0.0-RC2

Usage Example

<?php

require __DIR__ . "/vendor/autoload.php";

use Lazzard\FtpBridge\Logger\ArrayLogger;
use Lazzard\FtpBridge\Logger\LogLevel;
use Lazzard\FtpBridge\FtpBridge;

try {
   // Logger is optional
   $logger = new ArrayLogger;

   // set log levels prefixes
   LogLevel::setInfo('<--');
   LogLevel::setError('<--');
   LogLevel::setCommand('-->');

   // create bridge instance
   $ftp = new FtpBridge($logger);

   $hostname = 'foo@bar.com';
   $username = 'username';
   $password = 'password';

   if ($ftp->connect($hostname, 21)) {
       // connected
       if ($ftp->login($username, $password)) {
           // logged

           $ftp->send("PWD");
           $ftp->receive();

           // open a passive data connection
           if ($ftp->openPassive()) {
               $ftp->send("NLST .");
               $ftp->receive();

               $ftp->receiveData();
               $ftp->receive();
           }
       }

       $ftp->send("QUIT");
       $ftp->receive();
   }

   print_r($logger->getLogs());
   
} catch (Exception $ex) {
   print_r($ex->getMessage();
}

Result :

Array
(
    [0] => <-- 220---------- Welcome to Pure-FTPd [privsep] [TLS] ----------
220-You are user number 399 of 6900 allowed.
220-Local time is now 08:14. Server port: 21.
220-This is a private system - No anonymous login
220 You will be disconnected after 60 seconds of inactivity.

    [1] => --> USER username

    [2] => <-- 331 User username OK. Password required

    [3] => --> PASS password

    [4] => <-- 230-Your bandwidth usage is restricted
230 OK. Current restricted directory is /

    [5] => --> PWD

    [6] => <-- 257 "/" is your current location

    [7] => --> PASV

    [8] => <-- 227 Entering Passive Mode (185,27,134,11,205,216)

    [9] => --> NLST .

    [10] => <-- 150 Accepted data connection

    [11] => <-- .
..
.override
DO NOT UPLOAD FILES HERE
htdocs
lazzard.org

    [12] => <-- 226-Options: -a
226 6 matches total

    [13] => --> QUIT

    [14] => <-- 221-Goodbye. You uploaded 0 and downloaded 0 kbytes.
221 Logout.

)

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-05-17

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固