PHP Classes

File: docs/FtpWrapper.md

Recommend this page to a friend!
  Classes of El Amrani Chakir  >  PHP FTP Client Library  >  docs/FtpWrapper.md  >  Download  
File: docs/FtpWrapper.md
Role: Auxiliary data
Content type: text/markdown
Description: Auxiliary data
Class: PHP FTP Client Library
Manage files in remote FTP server
Author: By
Last change:
Date: 7 months ago
Size: 1,127 bytes
 

Contents

Class file image Download

FtpWrapper

You can use the FtpWrapper directly as a proxy class to the FTP extension functions (ftp_*), this class can handle FTP errors that may be raised with the built-in functions, and you can access the last error message using the FtpWrapper::getErrorMessage method.

Simple Example :

$wrapper = new FtpWrapper(ConnectionInterface $connection);
$wrapper->pasv(true);

if (!$wrapper->nlist('www/public_html')) {
    // The 'FtpWrapper' detects and catch FTP errors sent by the server
    // and you can get the last error message by calling the 'getFtpErrorMessage' method
    throw new \RuntimeException($wrapper->getErrorMessage());
}

Note :

Sometimes when an error occurs the remote server may not send any specific message, in this case our getFtpErrorMessage will return null, one solution to this is to create your own error message upon on what you try to do, this is a simple example:

$wrapper = new FtpWrapper($connection);

if (!$wrapper->pasv()) {
    throw new \RuntimeException($wrapper->getErrorMessage() 
        ?: "Unable to turn on the passive mode.");
}
For more information send a message to info at phpclasses dot org.