https://github.com/tofex/curl-ftp
FTP Client using Curl
https://github.com/tofex/curl-ftp
curl ftp ftps
Last synced: 4 days ago
JSON representation
FTP Client using Curl
- Host: GitHub
- URL: https://github.com/tofex/curl-ftp
- Owner: tofex
- License: mit
- Created: 2022-04-21T13:24:36.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2024-11-26T08:43:02.000Z (about 1 year ago)
- Last Synced: 2025-10-12T18:25:16.764Z (4 months ago)
- Topics: curl, ftp, ftps
- Language: PHP
- Homepage: https://www.tofex.de
- Size: 8.79 KB
- Stars: 1
- Watchers: 0
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# curl-ftp
Tofex Curl FTP provides a client based on Curl.
## Installation
```bash
$ 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
```php
$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
```php
$ftp->connect($hostName, $port, $userName, $password, $useSsl, $usePassiveMode, $timeout);
```
### Listing files
```php
$files = $ftp->ls();
print_r($files);
```
produces
```text
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
```php
$ftp->cd('directory/subdirectory');
```
### Read file contents
```php
$contents = $ftp->read('path/to/file.zip');
```
### Write to file
```php
$contents = 'file contents';
$ftp->write('path/to/file.txt', $contents);
```
### Remove a file/directory
```php
$ftp->rm('path/to/file.txt');
```
### Catching errors
All exceptions are thrown as standard `Exception` classes with the following message format:
```text
Could not handle content in path: {path} ({cURL error number})
```