class FTPService implements ServiceInterface (View source)

Constants

private CONFIG_HOSTNAME

private CONFIG_PORT

private CONFIG_TIMEOUT

private CONFIG_USERNAME

private CONFIG_PASSWORD

private CONFIG_ROOT

private CONFIG_TLS

private CONFIG_PASSIVE

private DEFAULT_PORT

private DEFAULT_TIMEOUT

private DEFAULT_TLS

private DEFAULT_PASSIVE

private MAX_RETRY_ATTEMPTS

private RETRY_DELAY_SECONDS

Methods

void
connect()

Connect to the FTP server with retry logic

void
disconnect()

Disconnect from the FTP server

void
changePath(string|null $path = null)

Change working directory

__destruct()

Destructor - ensure connection is closed

configure(array $config)

Configure service

mixed
getCurrentDirectory()

Return the current working directory.

array|bool|string
store(UploadedFile $file, string|null $location = null, array $option = [])

Store uploaded file to FTP server

Connection
getConnection()

Get ftp connection

bool
append(string $file, string $content)

Append content to file

bool
prepend(string $file, string $content)

Prepend content to file

string|null
get(string $file)

Get file content from FTP server

bool
put(string $file, string $content)

Put content to file on FTP server

array
files(string $dirname = '.')

List files in a directory

array
listDirectoryContents(string $directory = '.')

List directory contents

array
directories(string $dirname = '.')

List directories

bool
makeDirectory(string $dirname, int $mode = 0777)

Create a directory recursively

bool
makeActualDirectory(string $directory)

Create a single directory

bool
copy(string $source, string $target)

Copy file from source to target

bool
move(string $source, string $target)

Rename or move a file from source to target

bool
isFile(string $file)

Check if path is a file

bool
isDirectory(string $dirname)

Check if path is a directory

string
path(string $file)

Resolves a path.

bool
exists(string $path)

Check if file or directory exists

bool
delete(string $file)

Delete file from FTP server

Details

void connect()

Connect to the FTP server with retry logic

Return Value

void

Exceptions

RuntimeException

void disconnect()

Disconnect from the FTP server

Return Value

void

void changePath(string|null $path = null)

Change working directory

Parameters

string|null $path

Return Value

void

Exceptions

RuntimeException

__destruct()

Destructor - ensure connection is closed

static FilesystemInterface configure(array $config)

Configure service

Parameters

array $config

Return Value

FilesystemInterface

Exceptions

InvalidArgumentException

mixed getCurrentDirectory()

Return the current working directory.

Return Value

mixed

array|bool|string store(UploadedFile $file, string|null $location = null, array $option = [])

Store uploaded file to FTP server

Parameters

UploadedFile $file
string|null $location
array $option

Return Value

array|bool|string

Exceptions

InvalidArgumentException
RuntimeException

Connection getConnection()

Get ftp connection

Return Value

Connection

bool append(string $file, string $content)

Append content to file

Parameters

string $file
string $content

Return Value

bool

Exceptions

InvalidArgumentException
RuntimeException

bool prepend(string $file, string $content)

Prepend content to file

Parameters

string $file
string $content

Return Value

bool

Exceptions

InvalidArgumentException
RuntimeException
ResourceException

string|null get(string $file)

Get file content from FTP server

Parameters

string $file

Return Value

string|null

Exceptions

ResourceException
RuntimeException

bool put(string $file, string $content)

Put content to file on FTP server

Parameters

string $file
string $content

Return Value

bool

Exceptions

InvalidArgumentException
RuntimeException
ResourceException

array files(string $dirname = '.')

List files in a directory

Parameters

string $dirname

Return Value

array

Exceptions

RuntimeException

protected array listDirectoryContents(string $directory = '.')

List directory contents

Parameters

string $directory

Return Value

array

Exceptions

RuntimeException

array directories(string $dirname = '.')

List directories

Parameters

string $dirname

Return Value

array

Exceptions

RuntimeException

bool makeDirectory(string $dirname, int $mode = 0777)

Create a directory recursively

Parameters

string $dirname
int $mode

Return Value

bool

Exceptions

RuntimeException

protected bool makeActualDirectory(string $directory)

Create a single directory

Parameters

string $directory

Return Value

bool

Exceptions

RuntimeException

bool copy(string $source, string $target)

Copy file from source to target

Parameters

string $source
string $target

Return Value

bool

Exceptions

InvalidArgumentException
RuntimeException
ResourceException

bool move(string $source, string $target)

Rename or move a file from source to target

Parameters

string $source
string $target

Return Value

bool

Exceptions

InvalidArgumentException
RuntimeException

bool isFile(string $file)

Check if path is a file

Parameters

string $file

Return Value

bool

Exceptions

RuntimeException

bool isDirectory(string $dirname)

Check if path is a directory

Parameters

string $dirname

Return Value

bool

Exceptions

RuntimeException

string path(string $file)

Resolves a path.

Give the absolute path of a path

Parameters

string $file

Return Value

string

bool exists(string $path)

Check if file or directory exists

Parameters

string $path

Return Value

bool

Exceptions

RuntimeException

bool delete(string $file)

Delete file from FTP server

Parameters

string $file

Return Value

bool

Exceptions

InvalidArgumentException
RuntimeException