Download the PHP package verseles/flyclone without Composer
On this page you can find all versions of the php package verseles/flyclone. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download verseles/flyclone
More information about verseles/flyclone
Files in verseles/flyclone
Informations about the package flyclone
Verseles\Flyclone
PHP wrapper for rclone
Flyclone provides an intuitive, object-oriented interface for interacting with rclone
, the powerful command-line program for managing files on cloud storage.
Key Features
- Broad Provider Support: Works with numerous storage backends supported by rclone (see below).
- Fluent API: Simplifies rclone command execution.
- Progress Reporting: Built-in support for tracking transfer progress.
- Process Management: Handles rclone process execution, timeouts, and errors.
- Easy Configuration: Configure providers and rclone flags directly in PHP.
Supported Providers
Flyclone supports a wide array of rclone providers, including:
- Local filesystem (local)
- Amazon S3 & S3-compatible (e.g., MinIO) (s3)
- SFTP (sftp)
- FTP (ftp)
- Dropbox (dropbox)
- Google Drive (drive)
- Mega (mega)
- Backblaze B2 (b2)
- ...and many others supported by rclone. New providers can often be used by leveraging the generic
Provider
class or by adding specific classes via PR.
Installation
Requires PHP >= 8.4.
Usage
Configuration Basics
1. Provider Setup:
Each storage backend (local disk, S3 bucket, SFTP server, etc.) is represented by a Provider
class. You'll instantiate a provider with a unique nickname and its rclone configuration parameters.
2. Obscuring Secrets:
Rclone (and therefore Flyclone) often requires sensitive information like API keys or passwords. It's highly recommended to use rclone's obscure
feature for passwords. Flyclone provides a helper for this:
3. Rclone Binary Path (Optional):
Flyclone attempts to locate the rclone
binary automatically. If it's installed in a non-standard location, you can specify the path:
Instantiating Rclone
You create an Rclone
instance with one or two providers:
- One Provider: For operations on a single remote (e.g., listing files, creating directories, moving files within the same remote).
- Two Providers: For operations between two different remotes (e.g., copying from local to S3, syncing SFTP to Dropbox).
Common Operations
List files (ls
)
Create a directory (mkdir
)
Copy files/directories (copy
, copyto
)
Move files/directories (move
, moveto
)
Sync directories (sync
)
Delete files/directories (delete
, deletefile
, purge
, rmdir
)
Check existence (is_file
, is_dir
)
Read file content (cat
)
Write content to a file (rcat
)
Get size of files/directories (size
)
Upload a local file (upload_file
)
Download a remote file (download_to_local
)
Copy with progress reporting
Advanced Usage & Tips
- Rclone Documentation: Always refer to the official rclone documentation for detailed information on commands and flags. This library is a wrapper, so understanding rclone itself is beneficial.
-
Flags: Any rclone flag (e.g.,
--retries
,--max-depth
) can be passed as the last array argument to most Flyclone methods. Convert flags like--some-flag value
to['some-flag' => 'value']
or--boolean-flag
to['boolean-flag' => true]
. - Single Provider Operations: If you instantiate
Rclone
with only one provider, operations likecopy
ormove
will assume the source and destination are on that same provider (e.g., moving files within the same S3 bucket). - Global Rclone Settings:
Rclone::setFlags(['checksum' => true, 'verbose' => true])
: Set global flags for all subsequent rclone commands.Rclone::setEnvs(['RCLONE_BUFFER_SIZE' => '64M'])
: Set environment variables for rclone (these are usually prefixed withRCLONE_
automatically if not already).Rclone::setTimeout(300)
: Set the maximum execution time for rclone processes (seconds).Rclone::setIdleTimeout(120)
: Set the idle timeout for rclone processes (seconds).
- Error Handling: Flyclone throws specific exceptions based on rclone's exit codes (e.g.,
FileNotFoundException
,DirectoryNotFoundException
,TemporaryErrorException
). Catch these for robust error management.
To-do
- [x]
Add progress support - [x]
Add timeout support - [x]
Add more commands - [x]
Add tests- [x]
Use docker and docker compose for tests
- [x]
- [ ] Send meta details like file id in some storage system like google drive (e.g. for
lsjson
output).
Testing
Install Docker and Docker Compose, then run:
There are other test targets in the
makefile
(e.g.,test_dropbox
,test_gdrive
), but they require you to fill the.env
file with actual credentials for those services.
Contribution
You know the drill: Fork, branch, code, test, PR! Contributions are welcome.
License
Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International