"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files
Go azure-blobazure-blob-storageazure-filesbackblaze-b2cloud-storagedropboxencryptionftpfuse-filesystemgogolanggoogle-cloud-storagegoogle-driveonedriveopenstack-swiftrclones3sftpsyncwebdav
<?php
/*
PHP interface to librclone.so, using FFI ( Foreign Function Interface )
Create an rclone object
$rc = new Rclone( __DIR__ . '/librclone.so' );
Then call rpc calls on it
$rc->rpc( "config/listremotes", "{}" );
When finished, close it
$rc->close();
*/
class Rclone {
protected $rclone;
private $out;
public function __construct( $libshared )
{
$this->rclone = \FFI::cdef("
struct RcloneRPCResult {
char* Output;
int Status;
};
extern void RcloneInitialize();
extern void RcloneFinalize();
extern struct RcloneRPCResult RcloneRPC(char* method, char* input);
extern void RcloneFreeString(char* str);
", $libshared);
$this->rclone->RcloneInitialize();
}
public function rpc( $method, $input ): array
{
$this->out = $this->rclone->RcloneRPC( $method, $input );
$response = [
'output' => \FFI::string( $this->out->Output ),
'status' => $this->out->Status
];
$this->rclone->RcloneFreeString( $this->out->Output );
return $response;
}
public function close( ): void
{
$this->rclone->RcloneFinalize();
}
}