guzzlehttp/progress-subscriber 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

guzzlehttp/progress-subscriber

最新稳定版本:1.1.0

Composer 安装命令:

composer require guzzlehttp/progress-subscriber

包简介

Emits upload and download progress events

关键字:

README 文档

README

Adds upload and download progress events to transfers.

<?php

require 'vendor/autoload.php';

use GuzzleHttp\Client;
use GuzzleHttp\Subscriber\Progress\Progress;

$uploadCallback = function ($expected, $total, $client, $request) {
    printf("Upload: %d %% \r", 100 * ($total / $expected));
};

$downloadCallback = function ($expected, $total, $client, $request, $res) {
    printf("Download: %d %% \r", 100 * ($total / $expected));
};

$progress = new Progress($uploadCallback, $downloadCallback);

$client = new Client();
$client->put('http://httpbin.org/put', [
    'body'        => str_repeat('.', 10000),
    'subscribers' => [$progress],
]);

echo "\n";

Installing

This project can be installed using Composer. Add the following to your composer.json:

{
    "require": {
        "guzzlehttp/progress-subscriber": "~1.0"
    }
}

Constructor Options

The GuzzleHttp\Subscriber\Progress\Progress class accepts the following constructor arguments:

$uploadProgress
(callable) A function that is invoked each time data is read from the upload stream. The event receives the expected number of bytes to transfer in the first argument, the total number of bytes transferred in the second argument, the client used to send the request in the third argument, and the request being sent in the fourth argument.
$downloadProgress
(callable) A function that is invoked each time data is written to the response body. The event receives the expected number of bytes to download in the first argument, the total number of bytes downloaded in the second argument, the client that sent the request in the third argument, the request that was sent in the fourth argument, and the response being received in the fifth argument.

统计信息

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

GitHub 信息

  • Stars: 17
  • Watchers: 5
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2014-03-23

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固