PHP wrapper for rclone
supports local disk, dropbox, ftp, sftp, google drive, mega, s3 (any compatible) and others can be easily added via pr.
progress support.
composer require cloudatlas/flyclone
list local files
use cloudatlas\flyclone\rclone;
use cloudatlas\flyclone\providers\localprovider;
$left_side = new localprovider('mydisk'); // nickname
$rclone = new rclone($left_side);
var_dump($rclone->ls('/home/')); // returns array
list files from mega server
use cloudatlas\flyclone\rclone;
use cloudatlas\flyclone\providers\megaprovider;
$left_side = new megaprovider('myserver',[
'user'=>'[email protected]',
'pass'=> rclone::obscure('applesux')
]);
$rclone = new rclone($left_side);
var_dump($rclone->ls('/docs')); // returns array
copy from local disk to mega
use cloudatlas\flyclone\rclone;
use cloudatlas\flyclone\providers\localprovider;
use cloudatlas\flyclone\providers\megaprovider;
$left_side = new localprovider('mydisk'); // name
$right_side = new megaprovider('myremote',[
'user'=>'[email protected]',
'pass'=> rclone::obscure('4ppl35u*')
]);
$rclone = new rclone($left_side, $right_side);
$rclone->copy('/home/appleinc/index.html', '/docs'); // always true, otherwise throws error
move from local disk to the same local disk
use cloudatlas\flyclone\rclone;
use cloudatlas\flyclone\providers\localprovider;
$samedisk = new localprovider('mydisk'); // name
$rclone = new rclone($samedisk);
$rclone->copy('/home/appleinc/index.html', '/home/www/'); // always true, otherwise throws error
copy to dropbox with progress every sec
use cloudatlas\flyclone\rclone;
use cloudatlas\flyclone\providers\localprovider;
use cloudatlas\flyclone\providers\dropboxprovider;
$left_side = new localprovider('mydisk'); // nickname
$right_side = new dropboxprovider('myremote', [
'client_id' => 'your_dropbox_client_id',
'client_secret' => 'your_dropbox_client_secret',
'token' => 'your_dropbox_token',
]);
$rclone = new rclone($left_side, $right_side);
$rclone->copy('/home/appleinc/index.html', '/home/www/', [], static function ($type, $buffer) use ($rclone) {
var_dump($rclone->getprogress());
});
- of course, you need known how rclone works.
- rclone class and providers classes always support any flag listed at rclone documentation, often as 3rd argument. but
- any flag, parameter or option passed like
--parameter-here
, in this lib is a array like['parameter-here'='value', 'max-depth' => 3, 'any'=>'1']
- if you inform only one provider ('left side'), in commands like
copy
/move
we assume 'right side' as the same 'left side' provider. which means a copying/moving to the same disk. - we don't have a great doc for now so open a issue always you have a doubt. remember to be descriptful.
-
add progress support -
add timeout support -
add more commands -
add tests- use docker and docker compose for tests
- send meta details like file id in some storage system like google drive
install docker and docker compose, then run:
cp .env.example .env
make
there are others tests (test_all, test_gdrive, etc), but you'll need fill
.env
file properly.
you know how to do that.
Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International