laravel-aria2

Events

Laravel Aria2 dispatches events through Laravel's dispatcher when one is bound. Listen as you would for any other application event.

use Pullr\LaravelAria2\Events\TransferCompleted;
use Pullr\LaravelAria2\Events\TransferFailed;
use Pullr\LaravelAria2\Events\TransferProgressed;
 
Event::listen(TransferProgressed::class, function (TransferProgressed $event) {
$event->status->percent();
$event->transferId;
});

TransferStarted

Fired after a destination directory is accepted and before the downloader starts polling.

new TransferStarted(string $url, int|string|null $transferId = null)

TransferProgressed

Fired for every non-empty progress snapshot.

new TransferProgressed(TransferStatus $status, int|string|null $transferId = null)

TransferCompleted

Fired after aria2 reports complete and download() is about to return.

new TransferCompleted(TransferStatus $status, int|string|null $transferId = null)

TransferCancelled

Fired when the downloader stops because of a cancel signal. TransferFailed is also dispatched with the TransferCancelledException.

new TransferCancelled(int|string|null $transferId = null, ?string $gid = null)

TransferFailed

Fired for cancellation, aria2 errors, and unexpected exceptions. download() still throws after this event.

new TransferFailed(Throwable $exception, int|string|null $transferId = null)

Register listeners in your application's event service provider or with Event::listen().