Skip to content

Commit fa0c1ed

Browse files
committed
Updated README.md
1 parent 3aa2af5 commit fa0c1ed

File tree

1 file changed

+48
-66
lines changed

1 file changed

+48
-66
lines changed

README.md

Lines changed: 48 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -1,95 +1,77 @@
1-
# Lazzard/FtpBridge
2-
3-
[![Version](https://img.shields.io/github/v/release/lazzard/ftp-bridge?include_prereleases&style=flat-square)](https://packagist.org/packages/lazzard/ftp-bridge)
4-
[![Minimum PHP version](https://img.shields.io/badge/php-%3E%3D5.3.0-blue?style=flat-square)](https://packagist.org/packages/lazzard/ftp-bridge)
5-
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/lazzard/ftp-bridge/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/lazzard/ftp-bridge/?branch=master)
6-
[![LICENSE](https://img.shields.io/packagist/l/lazzard/ftp-bridge?style=flat-square)](https://packagist.org/packages/lazzard/ftp-bridge)
7-
8-
A low-level implementation library of the File Transfer Protocol (FTP) in PHP that follows the RFC 959 standards and others related RFC extensions.
9-
10-
> This library can be used to communicate with FTP servers, so you can send any FTP commands you want and receive data from the server very simply without writing the sockets/streams logic on yourself, in addition to that, the library provides a logging system to keep track of your FTP sessions.
11-
12-
## Requirements
1+
[![Version](https://img.shields.io/github/v/release/lazzard/ftp-bridge?include_prereleases)](https://packagist.org/packages/lazzard/ftp-bridge)
2+
[![Minimum PHP version](https://img.shields.io/badge/php-%3E%3D5.3.0-blue)](https://packagist.org/packages/lazzard/ftp-bridge)
3+
[![tests](https://github.com/lazzard/ftp-bridge/actions/workflows/tests.yml/badge.svg)](https://github.com/lazzard/ftp-bridge/actions/workflows/tests.yml)
4+
[![codecov](https://img.shields.io/codecov/c/github/lazzard/ftp-bridge)](https://codecov.io/gh/lazzard/ftp-bridge)
5+
[![Scrutinizer Code Quality](https://img.shields.io/scrutinizer/quality/g/lazzard/ftp-bridge/master)](https://scrutinizer-ci.com/g/lazzard/ftp-bridge/?branch=master)
6+
[![LICENSE](https://img.shields.io/packagist/l/lazzard/ftp-bridge)](https://packagist.org/packages/lazzard/ftp-bridge)
137

14-
* PHP version >= 5.3.0
15-
16-
## Installation
17-
18-
This library is available via composer.
8+
# Lazzard/FtpBridge
199

20-
**method 1 :**
10+
Allows free communication with FTP servers according to RFC959 specification and others related RFC extensions.
2111

22-
Require the exact version directly:
12+
## Getting started
2313

2414
```console
25-
composer require lazzard/ftp-bridge:v1.0.0-RC1
15+
composer require lazzard/ftp-bridge:v1.0.0-RC2
2616
```
2717

28-
**method 2 :**
18+
### Usage Example
2919

30-
Add this two lines in your `composer.json` file :
31-
32-
```json
33-
"minimum-stability": "dev",
34-
"prefer-stable": true
35-
```
36-
37-
Then require the package :
38-
39-
```console
40-
composer require lazzard/ftp-bridge
41-
```
20+
```php
21+
<?php
4222

43-
## Usage
23+
require __DIR__ . "/vendor/autoload.php";
4424

45-
```php
4625
use Lazzard\FtpBridge\Logger\ArrayLogger;
4726
use Lazzard\FtpBridge\Logger\LogLevel;
4827
use Lazzard\FtpBridge\FtpBridge;
4928

50-
require dirname(__DIR__) . "/vendor/autoload.php";
29+
try {
30+
// Logger is optional
31+
$logger = new ArrayLogger;
5132

52-
// Logger is optional
53-
$logger = new ArrayLogger();
33+
// set log levels prefixes
34+
LogLevel::setInfo('<--');
35+
LogLevel::setError('<--');
36+
LogLevel::setCommand('-->');
5437

55-
// set log levels prefixes
56-
LogLevel::setInfo('<--');
57-
LogLevel::setError('<--');
58-
LogLevel::setCommand('-->');
38+
// create bridge instance
39+
$ftp = new FtpBridge($logger);
5940

60-
// create bridge instance
61-
$ftp = new FtpBridge($logger);
41+
$hostname = '[email protected]';
42+
$username = 'username';
43+
$password = 'password';
6244

63-
$hostname = '[email protected]';
64-
$username = 'username';
65-
$password = 'password';
45+
if ($ftp->connect($hostname, 21)) {
46+
// connected
47+
if ($ftp->login($username, $password)) {
48+
// logged
6649

67-
if ($ftp->connect($hostname, 21)) {
68-
// connected
69-
if ($ftp->login($username, $password)) {
70-
// logged
50+
$ftp->send("PWD");
51+
$ftp->receive();
7152

72-
$ftp->send("PWD");
73-
$ftp->receive();
53+
// open a passive data connection
54+
if ($ftp->openPassive()) {
55+
$ftp->send("NLST .");
56+
$ftp->receive();
7457

75-
// open a passive data connection
76-
if ($ftp->openPassive()) {
77-
$ftp->send("NLST .");
78-
$ftp->receive();
79-
80-
$ftp->receiveData();
81-
$ftp->receive();
58+
$ftp->receiveData();
59+
$ftp->receive();
60+
}
8261
}
62+
63+
$ftp->send("QUIT");
64+
$ftp->receive();
8365
}
8466

85-
$ftp->send("QUIT");
86-
$ftp->receive();
67+
print_r($logger->getLogs());
68+
69+
} catch (Exception $ex) {
70+
print_r($ex->getMessage();
8771
}
88-
89-
print_r($logger->getLogs());
9072
```
9173

92-
**Result :**
74+
**Result :**
9375

9476
```
9577
Array
@@ -137,4 +119,4 @@ lazzard.org
137119
221 Logout.
138120
139121
)
140-
```
122+
```

0 commit comments

Comments
 (0)