PHP Classes

File: docs/

Recommend this page to a friend!
  Classes of El Amrani Chakir  >  PHP FTP Client Library  >  docs/  >  Download  
File: docs/
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


Class file image Download


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);

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.