1
1
# Lazzard/FtpClient
2
2
3
- [ ![ Downloads] ( https://img.shields.io/packagist/dm /lazzard/php-ftp-client )] ( https://packagist.org/packages/lazzard/php-ftp-client )
3
+ [ ![ Downloads] ( https://img.shields.io/packagist/dt /lazzard/php-ftp-client?style=flat-square )] ( https://packagist.org/packages/lazzard/php-ftp-client )
4
4
[ ![ Packagist Version] ( https://img.shields.io/packagist/v/lazzard/php-ftp-client?style=flat-square )] ( https://packagist.org/packages/lazzard/php-ftp-client )
5
5
[ ![ Minimum PHP version] ( https://img.shields.io/packagist/php-v/lazzard/php-ftp-client?color=%238892bf&style=flat-square )] ( https://packagist.org/packages/lazzard/php-ftp-client )
6
6
![ License] ( https://img.shields.io/packagist/l/lazzard/php-ftp-client?color=critical&style=flat-square )
7
7
8
8
A library that wraps the PHP FTP functions in an OOP way.
9
9
10
- * Note: This library aimed to be a full FTP/FTPS client solution for the old (5.5+) and newer PHP releases (7.2 +) that support FTP extension.*
10
+ * Note: This library aimed to be a full FTP/FTPS client solution for the old (5.5+) and newer PHP releases (8.0 +) that support FTP extension.*
11
11
12
12
## Requirements
13
13
@@ -34,35 +34,45 @@ then generate the autoload files :
34
34
composer dump-autoload
35
35
```
36
36
37
- ## Getting Started
37
+ ## Quick Start
38
38
39
- ### Usage
40
-
41
- Create an FTP connection
42
39
``` php
43
- $connection = new FtpConnection('host', 'foo', '1234');
44
- $connection->open();
45
- ```
40
+ <?php
46
41
47
- Or create a secure FTP connection
48
- ``` php
49
- $connection = new FtpSSLConnection('host', 'bar', '1234');
50
- $connection->open();
51
- ```
42
+ require __DIR__ . '/vendor/autoload.php';
52
43
53
- Configure the connection
44
+ use Lazzard\FtpClient\Config\FtpConfig;
45
+ use Lazzard\FtpClient\Connection\FtpConnection;
46
+ use Lazzard\FtpClient\Connection\FtpSSLConnection;
47
+ use Lazzard\FtpClient\Exception\FtpClientException;
48
+ use Lazzard\FtpClient\FtpClient;
54
49
55
- ``` php
56
- $config = new FtpConfig(ConnectionInterface $connection);
57
- $config->setPassive(true);
58
- ```
50
+ try {
51
+ // create a regular FTP connection
52
+ $connection = new FtpConnection("host", "username", "password");
53
+ // or a secure connection
54
+ $connection = new FtpSSLConnection("host", "username", "password");
55
+ // open the connection
56
+ $connection->open();
57
+
58
+ // configure the FTP connection
59
+ $config = new FtpConfig($connection);
60
+ // set the passive mode on (recommanded)
61
+ $config->setPassive(true);
59
62
60
- Start working with the base class ` FtpClient `
63
+ // Start working
64
+ $client = new FtpClient($connection);
65
+ print_r($client->getFeatures());
61
66
62
- ``` php
63
- $client = new FtpClient(ConnectionInterface $connection);
67
+ // close the connection
68
+ $connection->close();
69
+ } catch (FtpClientException $ex) { // catch this library exceptions with the 'FtpClientException' exception class
70
+ print_r($ex->getMessage());
71
+ }
64
72
```
65
73
74
+ ## Usage
75
+
66
76
#### upload/download
67
77
68
78
``` php
@@ -71,7 +81,11 @@ $client->download('path/to/remote/file', 'path/to/local/file');
71
81
72
82
// upload a local file to remote server
73
83
$client->upload('path/to/local/file', 'path/to/remote/file');
84
+ ```
85
+
86
+ #### Asynchrounous upload/download
74
87
88
+ ``` php
75
89
// download a remote file asynchronously
76
90
$client->asyncDownload('path/to/remote/file', 'path/to/local/file', function ($state) {
77
91
// do something every second while downloading this file
@@ -83,6 +97,8 @@ $client->asyncUpload('path/to/local/file', 'path/to/remote/file', function ($sta
83
97
}, 1, FtpWrapper::BINARY);
84
98
```
85
99
100
+ * Find more about asynchrounous stuff [ here] ( docs/FtpClient.md#asynchronous-transfer-operations ) .*
101
+
86
102
#### listing
87
103
88
104
``` php
@@ -235,43 +251,18 @@ $client->allocateSpace(2048);
235
251
// prevent the server from closing the connection and keeping it alive
236
252
$client->keepAlive();
237
253
```
238
- You can see all available methods [ here] ( docs/FtpClient.md ) .
239
-
240
- ## Full example
241
-
242
- ``` php
243
- try {
244
- // Connection
245
- $connection = new FtpConnection("localhost", "foo", "12345");
246
- $connection->open();
247
-
248
- // Configuration
249
- $config = new FtpConfig($connection);
250
- $config->setPassive(true);
251
-
252
- // FtpClient
253
- $client = new FtpClient($connection);
254
-
255
- // Start working
256
- print_r($client->getFeatures());
257
-
258
- // Close connection
259
- $connection->close();
260
- } catch (FtpClientException $ex) { // Use FtpClientException to catch this library exceptions
261
- echo($ex->getMessage());
262
- }
263
- ```
254
+ * You can see all available methods [ here] ( docs/FtpClient.md ) .*
264
255
265
256
## More documentation
266
257
267
- * [ Manipulate an FTP connection with ** FtpConnectionInterface ** ] [ 1 ]
268
- * [ Configure the connection instance with ** FtpConfig** ] [ 2 ]
269
- * [ Start working with the base class ** FtpClient** ] [ 3 ]
270
- * [ Sending FTP commands with ** FtpCommand** ] [ 4 ]
271
- * [ Using the ** FtpWrapper** Directly ] [ 5 ]
272
- * [ How i can run test units ? ] [ 6 ]
258
+ * [ Manipulate the FTP connection with ** ConnectionInterface ** . ] [ 1 ]
259
+ * [ Configure the connection instance with ** FtpConfig** . ] [ 2 ]
260
+ * [ Start working with the base class ** FtpClient** . ] [ 3 ]
261
+ * [ Sending FTP commands with ** FtpCommand** . ] [ 4 ]
262
+ * [ How to use the ** FtpWrapper** class directly. ] [ 5 ]
263
+ * [ Running the integration tests. ] [ 6 ]
273
264
274
- [ 1 ] : docs/FtpConnectionInterface .md
265
+ [ 1 ] : docs/ConnectionInterface .md
275
266
[ 2 ] : docs/FtpConfig.md
276
267
[ 3 ] : docs/FtpClient.md
277
268
[ 4 ] : docs/FtpCommand.md
@@ -283,11 +274,11 @@ try {
283
274
| Version | Status | Last Release | PHP Version |
284
275
| ------------| ---------------| --------------| -------------|
285
276
| 1.0.x | EOL | [ v1.0.2] [ 7 ] | >= 5.5 |
286
- | 1.3 .x | Latest | [ v1.3.5 ] [ 9 ] | >= 5.6 |
277
+ | 1.4 .x | Latest | [ v1.4.0 ] [ 9 ] | >= 5.6 |
287
278
288
279
[ 7 ] : https://github.com/lazzard/php-ftp-client/releases/tag/v1.0.2
289
280
[ 8 ] : https://github.com/lazzard/php-ftp-client/releases/tag/v1.1.0
290
- [ 9 ] : https://github.com/lazzard/php-ftp-client/releases/tag/v1.3.5
281
+ [ 9 ] : https://github.com/lazzard/php-ftp-client/releases/tag/v1.4.0
291
282
292
283
## License
293
284
0 commit comments