athlon1600 / php-curl-file-downloader
此包的最新版本(v1.0.2)没有可用的许可信息。
v1.0.2
2021-02-25 20:29 UTC
Requires
- ext-curl: *
- athlon1600/php-curl-client: ^1.0
Requires (Dev)
- phpunit/phpunit: ^7.0
This package is auto-updated.
Last update: 2024-08-25 03:52:15 UTC
README
使用PHP和cURL下载大文件
网上有很多关于如何做这件事的代码片段,但缺乏足够的库。
这将允许您使用cURL下载任何大小的文件,而不会耗尽内存。就是这样。
<?php use Curl\Client; use CurlDownloader\CurlDownloader; $browser = new Client(); $downloader = new CurlDownloader($browser); $response = $downloader->download("https://download.ccleaner.com/cctrialsetup.exe", function ($filename) { return './2020-06-07-' . $filename; }); if ($response->status == 200) { // 28,851,928 bytes downloaded in 20.041231 seconds echo number_format($response->info->size_download) . ' bytes downloaded in ' . $response->info->total_time . ' seconds'; }
它将自动猜测正在下载的资源文件名(就像网页浏览器那样!)并在需要时提供覆盖选项。
安装
composer require athlon1600/php-curl-file-downloader "^1.0"