class FTPService implements ServiceInterface (View source)

Methods

configure(array $config)

Configure service

void
connect()

Connect to the FTP server.

void
disconnect()

Disconnect from the FTP server.

void
setConnectionRoot($path = '')

Set the connection root.

Connection
getConnection()

Get ftp connextion

mixed
getCurrentDirectory()

Return the current working directory.

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

Store directly the upload file

bool
append(string $file, string $content)

Append content a file.

bool
prepend(string $file, string $content)

Write to the beginning of a file specify

bool
put(string $file, string $content)

Put other file content in given file

array
files(string $dirname = '.')

List files in a directory

array
directories(string $dirname = '.')

List directories

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

Create a directory

bool
makeActualDirectory(string $directory)

Create a directory.

string|null
get(string $filename)

Get file content

bool
copy(string $target, string $source)

Copy the contents of a source file to a target file.

bool
move(string $target, string $source)

Rename or move a source file to a target file.

bool
exists(string $filename)

Check that a file exists

bool
isFile(string $filename)

isFile alias of is_file.

bool
isDirectory(string $dirname)

isDirectory alias of is_dir.

string
path(string $filename)

Resolves a path.

bool
delete(string $file)

Delete file

array
listDirectoryContents(string $directory = '.')

List the directory content

Details

static FilesystemInterface configure(array $config)

Configure service

Parameters

array $config

Return Value

FilesystemInterface

void connect()

Connect to the FTP server.

Return Value

void

Exceptions

RuntimeException

void disconnect()

Disconnect from the FTP server.

Return Value

void

void setConnectionRoot($path = '')

Set the connection root.

Parameters

$path

Return Value

void

Connection getConnection()

Get ftp connextion

Return Value

Connection

mixed getCurrentDirectory()

Return the current working directory.

Return Value

mixed

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

Store directly the upload file

Parameters

UploadFile $file
string|null $location
array $option

Return Value

array|bool

Exceptions

InvalidArgumentException

bool append(string $file, string $content)

Append content a file.

Parameters

string $file
string $content

Return Value

bool

bool prepend(string $file, string $content)

Write to the beginning of a file specify

Parameters

string $file
string $content

Return Value

bool

Exceptions

bool put(string $file, string $content)

Put other file content in given file

Parameters

string $file
string $content

Return Value

bool

array files(string $dirname = '.')

List files in a directory

Parameters

string $dirname

Return Value

array

array directories(string $dirname = '.')

List directories

Parameters

string $dirname

Return Value

array

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

Create a directory

Parameters

string $dirname
int $mode

Return Value

bool

protected bool makeActualDirectory(string $directory)

Create a directory.

Parameters

string $directory

Return Value

bool

string|null get(string $filename)

Get file content

Parameters

string $filename

Return Value

string|null

bool copy(string $target, string $source)

Copy the contents of a source file to a target file.

Parameters

string $target
string $source

Return Value

bool

bool move(string $target, string $source)

Rename or move a source file to a target file.

Parameters

string $target
string $source

Return Value

bool

bool exists(string $filename)

Check that a file exists

Parameters

string $filename

Return Value

bool

bool isFile(string $filename)

isFile alias of is_file.

Parameters

string $filename

Return Value

bool

bool isDirectory(string $dirname)

isDirectory alias of is_dir.

Parameters

string $dirname

Return Value

bool

string path(string $filename)

Resolves a path.

Give the absolute path of a path

Parameters

string $filename

Return Value

string

bool delete(string $file)

Delete file

Parameters

string $file

Return Value

bool

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

List the directory content

Parameters

string $directory

Return Value

array