Skip to content

Commit

Permalink
Updated README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
AmraniCh committed Mar 1, 2022
1 parent 3aa2af5 commit fa0c1ed
Showing 1 changed file with 48 additions and 66 deletions.
114 changes: 48 additions & 66 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,95 +1,77 @@
# Lazzard/FtpBridge

[![Version](https://img.shields.io/github/v/release/lazzard/ftp-bridge?include_prereleases&style=flat-square)](https://packagist.org/packages/lazzard/ftp-bridge)
[![Minimum PHP version](https://img.shields.io/badge/php-%3E%3D5.3.0-blue?style=flat-square)](https://packagist.org/packages/lazzard/ftp-bridge)
[![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)
[![LICENSE](https://img.shields.io/packagist/l/lazzard/ftp-bridge?style=flat-square)](https://packagist.org/packages/lazzard/ftp-bridge)

A low-level implementation library of the File Transfer Protocol (FTP) in PHP that follows the RFC 959 standards and others related RFC extensions.

> 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.
## Requirements
[![Version](https://img.shields.io/github/v/release/lazzard/ftp-bridge?include_prereleases)](https://packagist.org/packages/lazzard/ftp-bridge)
[![Minimum PHP version](https://img.shields.io/badge/php-%3E%3D5.3.0-blue)](https://packagist.org/packages/lazzard/ftp-bridge)
[![tests](https://github.com/lazzard/ftp-bridge/actions/workflows/tests.yml/badge.svg)](https://github.com/lazzard/ftp-bridge/actions/workflows/tests.yml)
[![codecov](https://img.shields.io/codecov/c/github/lazzard/ftp-bridge)](https://codecov.io/gh/lazzard/ftp-bridge)
[![Scrutinizer Code Quality](https://img.shields.io/scrutinizer/quality/g/lazzard/ftp-bridge/master)](https://scrutinizer-ci.com/g/lazzard/ftp-bridge/?branch=master)
[![LICENSE](https://img.shields.io/packagist/l/lazzard/ftp-bridge)](https://packagist.org/packages/lazzard/ftp-bridge)

* PHP version >= 5.3.0

## Installation

This library is available via composer.
# Lazzard/FtpBridge

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

Require the exact version directly:
## Getting started

```console
composer require lazzard/ftp-bridge:v1.0.0-RC1
composer require lazzard/ftp-bridge:v1.0.0-RC2
```

**method 2 :**
### Usage Example

Add this two lines in your `composer.json` file :

```json
"minimum-stability": "dev",
"prefer-stable": true
```

Then require the package :

```console
composer require lazzard/ftp-bridge
```
```php
<?php

## Usage
require __DIR__ . "/vendor/autoload.php";

```php
use Lazzard\FtpBridge\Logger\ArrayLogger;
use Lazzard\FtpBridge\Logger\LogLevel;
use Lazzard\FtpBridge\FtpBridge;

require dirname(__DIR__) . "/vendor/autoload.php";
try {
// Logger is optional
$logger = new ArrayLogger;

// Logger is optional
$logger = new ArrayLogger();
// set log levels prefixes
LogLevel::setInfo('<--');
LogLevel::setError('<--');
LogLevel::setCommand('-->');

// set log levels prefixes
LogLevel::setInfo('<--');
LogLevel::setError('<--');
LogLevel::setCommand('-->');
// create bridge instance
$ftp = new FtpBridge($logger);

// create bridge instance
$ftp = new FtpBridge($logger);
$hostname = '[email protected]';
$username = 'username';
$password = 'password';

$hostname = '[email protected]';
$username = 'username';
$password = 'password';
if ($ftp->connect($hostname, 21)) {
// connected
if ($ftp->login($username, $password)) {
// logged

if ($ftp->connect($hostname, 21)) {
// connected
if ($ftp->login($username, $password)) {
// logged
$ftp->send("PWD");
$ftp->receive();

$ftp->send("PWD");
$ftp->receive();
// open a passive data connection
if ($ftp->openPassive()) {
$ftp->send("NLST .");
$ftp->receive();

// open a passive data connection
if ($ftp->openPassive()) {
$ftp->send("NLST .");
$ftp->receive();

$ftp->receiveData();
$ftp->receive();
$ftp->receiveData();
$ftp->receive();
}
}

$ftp->send("QUIT");
$ftp->receive();
}

$ftp->send("QUIT");
$ftp->receive();
print_r($logger->getLogs());

} catch (Exception $ex) {
print_r($ex->getMessage();
}

print_r($logger->getLogs());
```

**Result :**
**Result :**

```
Array
Expand Down Expand Up @@ -137,4 +119,4 @@ lazzard.org
221 Logout.

)
```
```

0 comments on commit fa0c1ed

Please sign in to comment.