lc5 / ftp
A simple object wrapper around native ftp_* functions.
1.1.1
2016-01-02 19:40 UTC
Requires
- php: >=5.4.0
Requires (Dev)
- phpunit/phpunit: 4.8.*
This package is not auto-updated.
Last update: 2025-04-12 19:19:53 UTC
README
A simple object wrapper around native ftp_* functions. Fully unit-tested.
Installation
Use Composer to install the package:
$ composer require lc5/ftp
Usage
use Lc5\Ftp\Ftp; try { $ftp = new Ftp('ftp.example.com', 'username', 'password'); //Save remote.txt to local.txt $ftp->get('local.txt', 'remote.txt', FTP_ASCII); //Actually you don't have to explicitly call close() //It will get called automatically as a part of the __destruct() method $ftp->close(); //For anonymous login you only need to pass the host address $ftp = new Ftp('ftp.example.com'); $ftp->pasv(true); //Get list of files in current directory and print them $files = $ftp->rawlist('.'); foreach ($files as $file) { echo $file . PHP_EOL; } } catch (\Exception $e) { echo $e->getMessage(); }
Extending
use Lc5\Ftp\Ftp; class MyFtp extends Ftp { public function myFunction() { $connection = $this->connect(); //your custom code... } }