PHP Класс FtpClient\FtpClient

Автор: Nicolas Tallefourtane ([email protected])
Наследование: implements Countabl\Countable
Показать файл Открыть проект Примеры использования класса

Защищенные свойства (Protected)

Свойство Тип Описание
$conn resource The connection with the server.

Открытые методы

Метод Описание
__call ( string $method, array $arguments ) : mixed Call an internal method or a FTP method handled by the wrapper.
__construct ( resource | null $connection = null ) Constructor.
__destruct ( ) Close the connection when the object is destroyed.
cleanDir ( string $directory ) : boolean Empty directory.
close ( ) : boolean Closes the current FTP connection.
connect ( string $host, boolean $ssl = false, integer $port = 21, integer $timeout = 90 ) : FTPClient Open a FTP connection.
count ( string $directory = '.', string | null $type = null, boolean $recursive = true ) : integer Count the items (file, directory, link, unknown).
dirSize ( string $directory = '.', boolean $recursive = true ) : integer Returns the total size of the given directory in bytes.
getConnection ( ) : resource Get the connection with the server.
getWrapper ( ) : FtpWrapper Get the wrapper.
help ( ) : array Get the help information of the remote FTP server.
isDir ( string $directory ) : boolean Check if a directory exist.
isEmpty ( string $directory ) : boolean Check if a directory is empty.
login ( string $username = 'anonymous', string $password = '' ) : FtpClient Logs in to an FTP connection.
mkdir ( string $directory, boolean $recursive = false ) : array Creates a directory.
modifiedTime ( string $remoteFile, string | null $format = null ) : integer Returns the last modified time of the given file.
nlist ( string $directory = '.', boolean $recursive = false, callable $filter = 'sort' ) : array Returns a list of files in the given directory.
parseRawList ( array $rawlist ) : array Parse raw list.
putAll ( string $source_directory, string $target_directory, integer $mode = FTP_BINARY ) : FtpClient Upload files.
putFromPath ( string $local_file ) : FtpClient Uploads a file to the server.
putFromString ( string $remote_file, string $content ) : FtpClient Uploads a file to the server from a string.
rawToType ( string $permission ) : string Convert raw info (drwx---r-x .
rawlist ( string $directory = '.', boolean $recursive = false ) : array Returns a detailed list of files in the given directory.
remove ( string $path, boolean $recursive = false ) : boolean Remove a file or a directory.
rmdir ( string $directory, boolean $recursive = true ) : boolean Remove a directory.
scanDir ( string $directory = '.', boolean $recursive = false ) : array Scan a directory and returns the details of each item.
setPhpLimit ( string | null $memory = null, integer $time_limit, boolean $ignore_user_abort = true ) : FtpClient Overwrites the PHP limit
up ( ) : FtpClient Changes to the parent directory.

Защищенные методы

Метод Описание
setWrapper ( FtpWrapper $wrapper ) : FtpClient Set the wrapper which forward the PHP FTP functions to use in FtpClient instance.

Описание методов

__call() публичный Метод

Wrap the FTP PHP functions to call as method of FtpClient object. The connection is automaticaly passed to the FTP PHP functions.
public __call ( string $method, array $arguments ) : mixed
$method string
$arguments array
Результат mixed

__construct() публичный Метод

Constructor.
public __construct ( resource | null $connection = null )
$connection resource | null

__destruct() публичный Метод

Close the connection when the object is destroyed.
public __destruct ( )

cleanDir() публичный Метод

Empty directory.
См. также: FtpClient::remove()
См. также: FtpClient::delete()
См. также: FtpClient::rmdir()
public cleanDir ( string $directory ) : boolean
$directory string
Результат boolean

close() публичный Метод

Closes the current FTP connection.
public close ( ) : boolean
Результат boolean

connect() публичный Метод

Open a FTP connection.
public connect ( string $host, boolean $ssl = false, integer $port = 21, integer $timeout = 90 ) : FTPClient
$host string
$ssl boolean
$port integer
$timeout integer
Результат FTPClient

count() публичный Метод

Count the items (file, directory, link, unknown).
public count ( string $directory = '.', string | null $type = null, boolean $recursive = true ) : integer
$directory string The directory, by default is the current directory.
$type string | null The type of item to count (file, directory, link, unknown)
$recursive boolean true by default
Результат integer

dirSize() публичный Метод

Returns the total size of the given directory in bytes.
public dirSize ( string $directory = '.', boolean $recursive = true ) : integer
$directory string The directory, by default is the current directory.
$recursive boolean true by default
Результат integer The size in bytes.

getConnection() публичный Метод

Get the connection with the server.
public getConnection ( ) : resource
Результат resource

getWrapper() публичный Метод

Get the wrapper.
public getWrapper ( ) : FtpWrapper
Результат FtpWrapper

help() публичный Метод

Get the help information of the remote FTP server.
public help ( ) : array
Результат array

isDir() публичный Метод

Check if a directory exist.
public isDir ( string $directory ) : boolean
$directory string
Результат boolean

isEmpty() публичный Метод

Check if a directory is empty.
public isEmpty ( string $directory ) : boolean
$directory string
Результат boolean

login() публичный Метод

Logs in to an FTP connection.
public login ( string $username = 'anonymous', string $password = '' ) : FtpClient
$username string
$password string
Результат FtpClient

mkdir() публичный Метод

Creates a directory.
См. также: FtpClient::rmdir()
См. также: FtpClient::remove()
См. также: FtpClient::put()
См. также: FtpClient::putAll()
public mkdir ( string $directory, boolean $recursive = false ) : array
$directory string The directory
$recursive boolean
Результат array

modifiedTime() публичный Метод

Return -1 on error
public modifiedTime ( string $remoteFile, string | null $format = null ) : integer
$remoteFile string
$format string | null
Результат integer

nlist() публичный Метод

Returns a list of files in the given directory.
public nlist ( string $directory = '.', boolean $recursive = false, callable $filter = 'sort' ) : array
$directory string The directory, by default is "." the current directory
$recursive boolean
$filter callable A callable to filter the result, by default is asort() PHP function. The result is passed in array argument, must take the argument by reference ! The callable should proceed with the reference array because is the behavior of several PHP sorting functions (by reference ensure directly the compatibility with all PHP sorting functions).
Результат array

parseRawList() публичный Метод

Parse raw list.
См. также: FtpClient::rawlist()
См. также: FtpClient::scanDir()
См. также: FtpClient::dirSize()
public parseRawList ( array $rawlist ) : array
$rawlist array
Результат array

putAll() публичный Метод

Upload files.
public putAll ( string $source_directory, string $target_directory, integer $mode = FTP_BINARY ) : FtpClient
$source_directory string
$target_directory string
$mode integer
Результат FtpClient

putFromPath() публичный Метод

Uploads a file to the server.
public putFromPath ( string $local_file ) : FtpClient
$local_file string
Результат FtpClient

putFromString() публичный Метод

Uploads a file to the server from a string.
public putFromString ( string $remote_file, string $content ) : FtpClient
$remote_file string
$content string
Результат FtpClient

rawToType() публичный Метод

..) to type (file, directory, link, unknown). Only the first char is used for resolving.
public rawToType ( string $permission ) : string
$permission string Example : drwx---r-x
Результат string The file type (file, directory, link, unknown)

rawlist() публичный Метод

Returns a detailed list of files in the given directory.
См. также: FtpClient::nlist()
См. также: FtpClient::scanDir()
См. также: FtpClient::dirSize()
public rawlist ( string $directory = '.', boolean $recursive = false ) : array
$directory string The directory, by default is the current directory
$recursive boolean
Результат array

remove() публичный Метод

Remove a file or a directory.
См. также: FtpClient::rmdir()
См. также: FtpClient::cleanDir()
См. также: FtpClient::delete()
public remove ( string $path, boolean $recursive = false ) : boolean
$path string The path of the file or directory to remove
$recursive boolean Is effective only if $path is a directory, {@see \FtpClient::rmdir()}
Результат boolean

rmdir() публичный Метод

Remove a directory.
См. также: FtpClient::mkdir()
См. также: FtpClient::cleanDir()
См. также: FtpClient::remove()
См. также: FtpClient::delete()
public rmdir ( string $directory, boolean $recursive = true ) : boolean
$directory string
$recursive boolean Forces deletion if the directory is not empty
Результат boolean

scanDir() публичный Метод

Scan a directory and returns the details of each item.
См. также: FtpClient::nlist()
См. также: FtpClient::rawlist()
См. также: FtpClient::parseRawList()
См. также: FtpClient::dirSize()
public scanDir ( string $directory = '.', boolean $recursive = false ) : array
$directory string
$recursive boolean
Результат array

setPhpLimit() публичный Метод

Overwrites the PHP limit
public setPhpLimit ( string | null $memory = null, integer $time_limit, boolean $ignore_user_abort = true ) : FtpClient
$memory string | null The memory limit, if null is not modified
$time_limit integer The max execution time, unlimited by default
$ignore_user_abort boolean Ignore user abort, true by default
Результат FtpClient

setWrapper() защищенный Метод

Set the wrapper which forward the PHP FTP functions to use in FtpClient instance.
protected setWrapper ( FtpWrapper $wrapper ) : FtpClient
$wrapper FtpWrapper
Результат FtpClient

up() публичный Метод

Changes to the parent directory.
public up ( ) : FtpClient
Результат FtpClient

Описание свойств

$conn защищенное свойство

The connection with the server.
protected resource $conn
Результат resource