定制 maestroerror/wget-download 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

maestroerror/wget-download

Composer 安装命令:

composer require maestroerror/wget-download

包简介

easy to use, chainable PHP class for downloading files, uses wget CLI

README 文档

README

easy to use, chainable PHP class for downloading files, uses wget CLI

Docs

I will try to provide some instructions, to better understand and use the main features of this little library.

installation

via Composer:

composer require maestroerror/wget-download  

Don't forget to require autoload.php file

from github:

git clone https://github.com/MaestroError/wget-download.git

Note: It needs wget command to be available from your terminal. Check with wget --help or install: Run apt-get install wget for linux or download for windows

Initialization of class (Construction)

You can construct object with 3 different ways: with array of configs, with string of URL or without any parameters (and provide them further). Which you choose, it depends on your needs:

// Construct with parameteres array
$conf = [
    "filename" => "/Home/Downloads/newFileName.mp4",
    "folder" => "YOUR FOLDER",
    "url" => "YOUR URL"
];
$file = new maestroerror\wgd($conf);

// Construct with URL only
$url = "YOUR URL";
$file = new maestroerror\wgd($url);

// Construct without parameters
$file = new maestroerror\wgd();
$file->folder("YOUR FOLDER")->name("/Home/Downloads/newFileName.mp4")->url("YOUR URL");

Options

set speed limit:

$file->speedLimit("500k");

enable continue after the interrupt, so if the internet connection stopped it will automatically resume the download after the connection is restored:

$file->continueIfStopped();

$checkCertificate is defined in wgd class as protected boolean property and by default it is set to false, you can use secure method, to allow HTTPS certificate check for specific downloads:

$file->secure();

By default silent (download in background) mode is enabled, but for some specific downloads you can specify conditions:

$file->silent();
$file->wait(); // Waits before downloaded

Sometimes you should use a user agent for download. first, you need to allow and after set user agent for your download:

$file->allowUserAgent()->userAgent($user_agent_string)

for multiple .txt downloads, you need .txt file with urls (line by line). Like in user agent case, first, allow multiple download with multiple method and then give .txt file to run:

$file->multiple()->file($filepath);

Logs

default log file is defined as protected property in wgd class protected string $logFile = "wgetlog.txt";, but if you need, you can specify with setLog method:

$file->setLog("/Home/Downloads/newFileLog.txt");
$file->setLog("newFileLog.txt");

Run

The last step is an execution, you can start your download with run method: $file->run().
Now let's say, we need to download file on background, with secure connection, set speed limit 1MB and allow continue:

$conf = [
    "filename" => "/Home/Downloads/newFileName.mp4",
    "folder" => "YOUR FOLDER",
    "url" => "YOUR URL"
];
$file = new maestroerror\wgd($conf);
$file->setLog("newFileLog.txt")->silent()->secure()->speedLimit("1m")->continueIfStopped()->run()

To Do

  • Search for todo comments and fix them
  • Add more use cases in examples
  • Add config files
  • Update documentation
  • New release

maestroerror/wget-download 适用场景与选型建议

maestroerror/wget-download 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 12 次下载、GitHub Stars 达 2, 最近一次更新时间为 2021 年 07 月 08 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 maestroerror/wget-download 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 maestroerror/wget-download 我们能提供哪些服务?
定制开发 / 二次开发

基于 maestroerror/wget-download 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 12
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 2
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-07-08