Skip to content

xp-framework/ftp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FTP protocol support for the XP Framework

Build status on GitHub XP Framework Module BSD Licence Requires PHP 7.0+ Supports PHP 8.0+ Latest Stable Version

Userland FTP protocol implementation, no dependency on PHP's ftp extension.

Client

Example: Uploading

use peer\ftp\{FtpConnection, FtpTransfer};
use io\File;

$c= (new FtpConnection('ftp://user:pass@example.com/'))->connect();

// Upload logo.png to the connection's root directory
$c->rootDir()->file('logo.png')->uploadFrom(new File('logo.png'));

// Upload from a stream using ASCII mode
$c->rootDir()->file('README.md')->uploadFrom(
  new MemoryInputStream('Read me first!'),
  FtpTransfer::ASCII
);

$c->close();

Example: Listing

use peer\ftp\FtpConnection;

$c= (new FtpConnection('ftp://user:pass@example.com/'))->connect();

// List root directory's contents
foreach ($c->rootDir()->entries() as $entry) {
  Console::writeLine('- ', $entry);
}

$c->close();