RPC Client
The fluent builder covers most applications. When you need a single JSON-RPC call, use the client:
use Pullr\LaravelAria2\Facades\Aria2; $gid = Aria2::client()->addUri(['https://example.com/file.iso'], ['dir' => '/tmp']);$status = Aria2::client()->tellStatus($gid);$files = Aria2::client()->getFiles($gid);Aria2::client()->forceRemove($gid);Aria2::client()->removeDownloadResult($gid);
Methods
addUri()
Start a download and return its GID.
$gid = Aria2::client()->addUri( ['https://example.com/file.iso'], ['dir' => '/tmp', 'continue' => 'true'],);
tellStatus()
Get the current status. Pass an optional list of keys to limit the payload.
Aria2::client()->tellStatus($gid, ['status', 'completedLength', 'totalLength']);
getFiles()
List files belonging to a download.
Aria2::client()->getFiles($gid);
forceRemove()
Force-remove a download from aria2.
Aria2::client()->forceRemove($gid);
removeDownloadResult()
Remove a completed result from aria2 memory. The RPC result must be OK.
Aria2::client()->removeDownloadResult($gid);
call()
Call an arbitrary JSON-RPC method. The RPC secret is prepended automatically.
Aria2::client()->call('aria2.getGlobalStat');Aria2::client()->call('aria2.tellActive');
Authentication
When ARIA2_RPC_SECRET (or aria2.rpc.secret) is set, every request prepends token:<secret> as the first JSON-RPC parameter.
Errors
HTTP failures, malformed JSON, JSON-RPC error objects, and missing result fields throw RpcException. The exception exposes method() and payload() for diagnostics.
What this package does not do
The client talks to a daemon that is already running. It does not install aria2c, write aria2.conf, or register Artisan commands such as aria2:start. Keep process supervision in the host application.