@@ -16,18 +16,24 @@ A library that wraps the PHP FTP functions in an OOP way.
16
16
17
17
## Installation
18
18
19
- The recommended way to install this library is through composer:
19
+ The recommended way to install this library is through composer :
20
20
21
21
``` console
22
22
composer require lazzard/php-ftp-client
23
23
```
24
24
25
- or just clone the repo using git:
25
+ or just clone the repo using git :
26
26
27
27
``` bash
28
28
git clone https://github.com/lazzard/php-ftp-client
29
29
```
30
30
31
+ then generate the autoload files :
32
+
33
+ ``` console
34
+ composer dump-autoload
35
+ ```
36
+
31
37
## Getting Started
32
38
33
39
### Usage
@@ -71,24 +77,24 @@ $client->asyncDownload('illustrations/assets.zip', 'assets.zip', function ($stat
71
77
72
78
// upload a remote file asynchronously
73
79
$client->asyncUpload('wallpapers.zip', 'public_html', function ($state) {
74
- // do something
80
+ // do something
75
81
});
76
82
```
77
83
78
84
#### listing
79
85
80
86
``` php
81
87
// get files names within an FTP directory
82
- $client->listDirectory ('public_html');
88
+ $client->listDir ('public_html');
83
89
84
90
// get only directories
85
- $client->listDirectory ('public_html', FtpClient::DIR_TYPE);
91
+ $client->listDir ('public_html', FtpClient::DIR_TYPE);
86
92
87
93
// get detailed information of each file within an FTP directory including the file path
88
- $client->listDirectoryDetails ('public_html');
94
+ $client->listDirDetails ('public_html');
89
95
90
96
// recursively
91
- $client->listDirectoryDetails ('public_html', true);
97
+ $client->listDirDetails ('public_html', true);
92
98
```
93
99
94
100
#### remove/rename
@@ -98,16 +104,29 @@ $client->listDirectoryDetails('public_html', true);
98
104
$client->removeFile($remoteFile);
99
105
100
106
// remove a directory (this will remove all the file within the directory)
101
- $client->removeDirectory ($directory);
107
+ $client->removeDir ($directory);
102
108
103
109
// rename an FTP file/directory
104
110
$client->rename($remoteFile, $newName);
105
111
```
106
112
107
- #### copy file/directory from local
113
+ #### copy
108
114
``` php
109
- // copy a local directory to the giving path in the server
115
+ // copy a local file/ directory to server
110
116
$client->copyFromLocal('media/images', 'htdocs');
117
+
118
+ // copy a remote file/directory to local machine
119
+ $client->copyToLocal('htdocs/images', 'images');
120
+ ```
121
+
122
+ #### search
123
+
124
+ ``` php
125
+ // get all png files within the 'public_html' directory with their details
126
+ $client->find('/.*\.png$/i', 'public_html');
127
+
128
+ // recursively
129
+ $client->find('/.*\.png$/i', 'public_html', true);
111
130
```
112
131
113
132
#### size
@@ -131,7 +150,7 @@ $client->createFile('public_html/example.txt', 'Hello world!!');
131
150
132
151
// create an FTP directory
133
152
// note: this method supports recursive directory creation
134
- $client->createDirectory ('public_html/assets');
153
+ $client->createDir ('public_html/assets');
135
154
```
136
155
137
156
#### remove/rename
@@ -141,7 +160,7 @@ $client->createDirectory('public_html/assets');
141
160
$client->removeFile($remoteFile);
142
161
143
162
// remove an FTP directory (be careful all the files within this directory will be removed)
144
- $client->removeDirectory ($directory);
163
+ $client->removeDir ($directory);
145
164
146
165
// rename an FTP file/directory
147
166
$client->rename($remoteFile, $newName);
@@ -216,11 +235,11 @@ $client->getFeatures();
216
235
$client->getSystem();
217
236
218
237
// send a request to allocate a space of bytes for the next transfer operation
219
- // note: not all servers requires this
238
+ // some FTP servers requires this before transfer operations
220
239
$client->allocateSpace(2048);
221
240
222
241
// prevent the server from closing the connection and keeping it alive
223
- $client->keepConnectionAlive ();
242
+ $client->keepAlive ();
224
243
```
225
244
You can see all available methods [ here] ( docs/FtpClient.md ) .
226
245
@@ -270,11 +289,11 @@ try {
270
289
| Version | Status | Last Release | PHP Version |
271
290
| ------------| ---------------| --------------| -------------|
272
291
| 1.0.x | EOL | [ v1.0.2] [ 7 ] | >= 5.5 |
273
- | 1.3.x | Latest | [ v1.3.0 ] [ 9 ] | >= 5.6 |
292
+ | 1.3.x | Latest | [ v1.3.3 ] [ 9 ] | >= 5.6 |
274
293
275
294
[ 7 ] : https://github.com/lazzard/php-ftp-client/releases/tag/v1.0.2
276
295
[ 8 ] : https://github.com/lazzard/php-ftp-client/releases/tag/v1.1.0
277
- [ 9 ] : https://github.com/lazzard/php-ftp-client/releases/tag/v1.3.0
296
+ [ 9 ] : https://github.com/lazzard/php-ftp-client/releases/tag/v1.3.3
278
297
279
298
## License
280
299
0 commit comments