Skip to content

トランスポート層とFTP層のエラーを区別出来るようにしたFTPクライアント

Notifications You must be signed in to change notification settings

ngyuki/php-ftp-client

Repository files navigation

PHP FTP Client

Build Status Coverage Status

FTP client library that does not depend on FTP extension.

Install

$ php composer.phar require "ngyuki/php-ftp-client:*"

Requirements

  • PHP 5.3.0 or later

Example

<?php
require __DIR__ . '/../vendor/autoload.php';

use ngyuki\FtpClient\FtpClient;
use ngyuki\FtpClient\FtpException;
use ngyuki\FtpClient\TransportException;

$ftp = new FtpClient();

try
{
    $ftp->connect("example.net", 21, 10);
    $ftp->login("hoge", "piyo");

    echo "nlist...\n";
    echo implode("\n", $ftp->nlist("."));
    echo "\n\n";

    echo "put...\n";
    $ftp->put("test.txt", "testing");

    $ftp->quit();

    echo "done.\n";
}
catch (FtpException $ex)
{
    echo "FtpException: {$ex->getResponse()->getResponseLine()}\n";
}
catch (TransportException $ex)
{
    echo "TransportException: {$ex->getMessage()}\n";
}

About

トランスポート層とFTP層のエラーを区別出来るようにしたFTPクライアント

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages