tofex / curl-ftp
This package is abandoned and no longer maintained.
The author suggests using the fewedev/curl-ftp package instead.
Tofex Curl FTP
2.0.0
2024-11-26 08:42 UTC
Requires
- php: >=7.1.0
- fewedev/base: ^1.1
README
Tofex Curl FTP provides a client based on Curl.
Installation
$ composer require tofex/curl-ftp
License
Tofex Curl FTP is licensed under the MIT License - see the LICENSE file for details.
Usage
Creating a connection
$ftp = new Client(); $ftp->open([ 'host' => 'ftp.example.com', 'user' => 'username', 'password' => 'password', 'port' => 990, 'ssl' => true, 'passive' => true, 'timeout' => 30 ]);
Alternatively you can create a connection using the connect()
method
$ftp->connect($hostName, $port, $userName, $password, $useSsl, $usePassiveMode, $timeout);
Listing files
$files = $ftp->ls(); print_r($files);
produces
Array
(
[0] => Array
(
[text] => file_1.zip
[id] => /file_1.zip
)
[1] => Array
(
[text] => file_2.zip
[id] => /file_2.zip
)
)
Setting/changing current directory
$ftp->cd('directory/subdirectory');
Read file contents
$contents = $ftp->read('path/to/file.zip');
Write to file
$contents = 'file contents'; $ftp->write('path/to/file.txt', $contents);
Remove a file/directory
$ftp->rm('path/to/file.txt');
Catching errors
All exceptions are thrown as standard Exception
classes with the following message format:
Could not handle content in path: {path} ({cURL error number})