Zum Hauptinhalt springen

Zymba Documentation

FTP.Client

object @FTP.Client(@Base) {
construct(string $server, string $username, string $password, int $timeout) {}
append(string $path, string $target): $this {}
close() {}
countDirectories(string $path): int {}
countFiles(string $path): int {}
createDirectory(string $path): $this {}
delete(string $path): $this {}
disablePassiveMode(): $this {}
download(string $path, string $target): $this {}
echo(string $path): $this {}
enablePassiveMode(): $this {}
execute(string $command): object {}
exists(string $path): bool {}
exit() {}
getLastModified(string $path): int {}
getSize(string $path): int {}
getWorkingDirectory(): string {}
isConnected(): bool {}
isDirectory(string $path): bool {}
listDirectories(string $path): object {}
listFiles(string $path): object {}
move(string $path, string $target): $this {}
read(string $path, ?int $length, int $position): string {}
readCSV(string $path, string $delimiter): object {}
readJSON(string $path): mixed {}
setPermissions(string $path, int $mode): $this {}
setTimeout(int $timeout): $this {}
setWorkingDirectory(string $path): $this {}
upload(string $path, string $target, int $position): $this {}
write(string $path, string $string, ?int $length, int $position): int {}
}

FTP client prototype.

Prototype

Base

Methods

Opens a FTP connection to a specific server and attempts login.

$this.construct(string $server, string $username, string $password, int $timeout): void
Parameters
NameTypeValueDefault
serverstring""
usernamestring"anonymous"
passwordstring""
timeoutint60

Appends an existing file to a specific target.

$this.append(string $path, string $target): this
Parameters
NameTypeValueDefault
pathstring""
targetstring""
Returns
TypeValue
$this

Closes this client and frees its associated resources.

$this.close(): void

Counts the total number of subdirectories in an existing directory.

$this.countDirectories(string $path): int
Parameters
NameTypeValueDefault
pathstring""
Returns
TypeValue
int

Counts the total number of files in an existing directory.

$this.countFiles(string $path): int
Parameters
NameTypeValueDefault
pathstring""
Returns
TypeValue
int

Creates a directory.

$this.createDirectory(string $path): this
Parameters
NameTypeValueDefault
pathstring""
Returns
TypeValue
$this

Deletes an existing file.

$this.delete(string $path): this
Parameters
NameTypeValueDefault
pathstring""
Returns
TypeValue
$this

Disables passive mode for this client.

$this.disablePassiveMode(): this
Returns
TypeValue
$this

Downloads an existing file to a specific target.

$this.download(string $path, string $target): this
Parameters
NameTypeValueDefault
pathstring""
targetstring""
Returns
TypeValue
$this

Outputs the content of an existing file.

$this.echo(string $path): this
Parameters
NameTypeValueDefault
pathstring""
Returns
TypeValue
$this

Enables passive mode for this client.

$this.enablePassiveMode(): this
Returns
TypeValue
$this

Executes a FTP command and returns its output.

$this.execute(string $command): object
Parameters
NameTypeValueDefault
commandstring""
Returns
TypeValue
object[line, ...]
null

Determines whether a path exists.

$this.exists(string $path): bool
Parameters
NameTypeValueDefault
pathstring""
Returns
TypeValue
bool

Closes this client and frees its associated resources for the purpose of contextualization.

$this.exit(): void

Gets the timestamp for the last modification date and time of an existing file.

$this.getLastModified(string $path): int
Parameters
NameTypeValueDefault
pathstring""
Returns
TypeValue
int
null

Gets the size of an existing file in number of bytes.

$this.getSize(string $path): int
Parameters
NameTypeValueDefault
pathstring""
Returns
TypeValue
int
null

Gets the path of the current working directory.

$this.getWorkingDirectory(): string
Returns
TypeValue
string
$this.isConnected(): bool
Returns
TypeValue
bool

Determines whether a path exists and targets a directory.

$this.isDirectory(string $path): bool
Parameters
NameTypeValueDefault
pathstring""
Returns
TypeValue
bool
$this.listDirectories(string $path): object
Parameters
NameTypeValueDefault
pathstring""
Returns
TypeValue
object[filename, ...]
$this.listFiles(string $path): object
Parameters
NameTypeValueDefault
pathstring""
Returns
TypeValue
object[filename, ...]

Moves an existing file to a specific target.

$this.move(string $path, string $target): this
Parameters
NameTypeValueDefault
pathstring""
targetstring""
Returns
TypeValue
$this

Reads the content of an existing file in binary mode up to a specific byte-based length.

$this.read(string $path, ?int $length, int $position): string
Parameters
NameTypeValueDefault
pathstring""
length?intmaximum length
positionint0
Returns
TypeValue
string
$this.readCSV(string $path, string $delimiter): object
Parameters
NameTypeValueDefault
pathstring""
delimiterstring";"
Returns
TypeValue
object[[value, ...], ...]
$this.readJSON(string $path): mixed
Parameters
NameTypeValueDefault
pathstring""
Returns
TypeValue
mixed

Sets the permissions of an exiting file to a specific numeric mode.

$this.setPermissions(string $path, int $mode): this
Parameters
NameTypeValueDefault
pathstring""
modeint0o777
Returns
TypeValue
$this

Sets the timeout period of this client to a specific number of seconds.

$this.setTimeout(int $timeout): this
Parameters
NameTypeValueDefault
timeoutint60
Returns
TypeValue
$this

Sets the path of the working directory.

$this.setWorkingDirectory(string $path): this
Parameters
NameTypeValueDefault
pathstring""
Returns
TypeValue
$this

Uploads an existing file to a specific target.

$this.upload(string $path, string $target, int $position): this
Parameters
NameTypeValueDefault
pathstring""
targetstring""
positionint0
Returns
TypeValue
$this

Writes a string to a file in binary mode up to a specific byte-based length and returns the number of bytes written.

$this.write(string $path, string $string, ?int $length, int $position): int
Parameters
NameTypeValueDefault
pathstring""
stringstring""
length?intmaximum length
positionint0
Returns
TypeValue
int