Simple and comfortable library for work with FTP protocol. Supports:
- fluent interface
- callbacks
- ftp-ssl connect
- errors bag
- all available functions PHP-FTP
- easy in integration with any php-framework
- /* in next release*/
- PSR\LoggerInterface
- async operations
- retry operations
You can install the package via composer:
composer require kartulin/php-ftp-droid
use Kartulin\FtpDroid\FtpDroid;
// fast example
$ftp = FtpDroid::connect('127.0.0.1', $ssl = false, $port = 21, $timeout = 90)
->login('username', 'password')
->get($local_filename, $remote_filename, $mode = FTP_BINARY, $offset = 0)
->callback(function (FtpDroid $ftp){
if ($ftp->result){
// you logic here...
//see $ftp->errors...
}
})->chdir($directory)
->close();
All methods are good are documented. You can also read the documentaion on php.net
Call every method return the object of FtpDroid client:
var_dump($ftp);
Kartulin\FtpDroid\FtpDroid {#3 ▼
+hostname: "127.0.0.1"
+ssl: false
+port: 21
+timeout: 90
-handler: FTP\Connection {#2}
#logger: null
+result: true // the result of last method
+errors: array:1 [▼
1655710692 => "login"
// [timestamp_error => "the name of the method that received the error from the ftp server"]
]
You can use unlimited callbacks:
$ftp = FtpDroid::connect('127.0.0.1', $ssl = false, $port = 21, $timeout = 90)
->login('username', 'password')
->get()
->callback(function (FtpDroid $ftp){
// you logic 1 here...
})->chdir()
->callback(function (FtpDroid $ftp){
// you logic 2 here...
})
->method()
->callback();
cooming soon (PHPUnit and PhpStan)
Please see CHANGELOG for more information what has changed recently.
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
The MIT License (MIT). Please see License File for more information.