laravel-aria2

Progress

Each time a field changes, the package emits a TransferStatus snapshot to your onProgress callback and dispatches TransferProgressed.

use Pullr\LaravelAria2\Transfer\TransferStatus;
 
Aria2::url($url)
->dir($directory)
->onProgress(function (TransferStatus $status) {
$status->gid();
$status->status();
$status->percent();
$status->completedBytes();
$status->totalBytes();
$status->speed();
$status->displayName();
})
->download();

Snapshots only contain fields that changed. A call may include gid without percent. Use has() when you need to distinguish missing from null:

if ($status->has('progress')) {
$pull->progress = $status->percent();
}

Accessors

| Method | Field | Type | | --- | --- | --- | | gid() | gid | ?string | | status() | status | ?string | | percent() | progress | ?int (0–100) | | completedBytes() | completed_bytes | ?int | | totalBytes() | total_bytes | ?int | | speed() | speed | ?string (1.5MiB, 512KiB, 42B) | | displayName() | display_name | ?string | | has($key) | — | bool | | get($key) | — | mixed | | toArray() | — | array<string, mixed> |

Percent never goes backwards. Magnet and torrent metadata phases are withheld until the payload GID is active, so a 100% metadata fetch does not look like a finished download.

Seeding previous values

When a worker restarts mid-transfer, pass the last known values so the next snapshots stay consistent:

Aria2::url($pull->url)
->dir($pull->directory)
->id($pull->id)
->gid($pull->gid)
->previousProgress($pull->progress)
->previousSpeed($pull->speed)
->previousTotalBytes($pull->total_bytes)
->previousDisplayName($pull->display_name)
->download();