PHP code example of somov / yii2-large-file-downloader
1. Go to this page and download the library: Download somov/yii2-large-file-downloader library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
somov / yii2-large-file-downloader example snippets
/** @var \somov\lfd\Client $client */
$client = Yii::createObject([
'class' => \somov\lfd\Client::class,
//'threadCount' => 5,
//'resumeDownload' => true,
//'tmpAlias' => '@runtime/downloads'
]);
$client->on(\somov\lfd\Client::EVENT_PROGRESS, function ($event){
/** @var \somov\lfd\ProgressEvent $event */
echo $event->percent;
});
//Download file
$fileName = $client->download("https://sample-videos.com/video123/mp4/720/big_buck_bunny_720p_1mb.mp4")->data;
$size = filesize($fileName);
echo $size;
'controllerMap' => [
'downloader' => '\somov\lfd\CommandController'
],
php composer.phar