private function download($src, $target, $output) { $output->writeln("Downloading multimedia files to init the database:"); $progress = new \Symfony\Component\Console\Helper\ProgressBar($output, 100); $progress->start(); $ch = curl_init($src); $targetFile = fopen($target, 'wb'); curl_setopt($ch, CURLOPT_FILE, $targetFile); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_NOPROGRESS, false); curl_setopt($ch, CURLOPT_PROGRESSFUNCTION, function ($c, $downloadSize, $downloaded, $uploadSize, $uploaded) use($progress) { $percentage = $downloaded > 0 && $downloadSize > 0 ? round($downloaded / $downloadSize, 2) : 0.0; $progress->setProgress($percentage * 100); }); curl_exec($ch); $statusCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); fclose($targetFile); curl_close($ch); $progress->finish(); return 200 == $statusCode; }