2017 © Pedro Peláez
 

library multi-curl

image

shellus/multi-curl

  • Wednesday, December 14, 2016
  • by shellus
  • Repository
  • 3 Watchers
  • 7 Stars
  • 4 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 3 Forks
  • 0 Open issues
  • 6 Versions
  • 0 % Grown

The README.md

Multi-curl

PHP异步CURL,轻易的在PHP中进行并发的http请求,可用于针对复杂接口的压力测试, (*1)

特点

  • 自动的编码解码,使用FormRequest来自动编码form表单提交,使用JsonResponse来自动解码返回的json数据
  • 和其他压力测试工具不同,本公举支持POST、请求构造等特性。

安装

composer require shellus/multi-curl

示例代码


/** * 单请求多并发示例 * User: shellus-out * Date: 2016/11/25 * Time: 10:16 */ // 处理接收到的数据 function handleResult(\MultiCurl\Response $response){ $info = $response -> getInfo(); $text = substr($response -> getContent(), 0, 200); $text = str_replace("\r\n", "\n", $text); $text = str_replace("\n", "", $text); var_dump('url: ' . $info['url'], 'content: ' . $text); } // 并发50 $m = new \MultiCurl\MultiCurl(50); for($i =0; $i < 10; $i++){ $url = 'http://www.xjflcp.com/game/SelectDate'; $data = ['selectDate'=>'20161122']; $request = new MultiCurl\FormRequest($url, $data); $request -> setClosure('handleResult'); $m -> pushRequest($request); } $m -> exec();

更多例子请查阅examples文件夹, (*2)

本项目参考了以下页面

  • php curl文档 : http://php.net/manual/en/function.curl-multi-init.php

The Versions

14/12 2016

dev-guzzle/guzzle

dev-guzzle/guzzle

  Sources   Download

The Requires

 

by Avatar shellus

25/11 2016

dev-dev-small-multi-curl

dev-dev-small-multi-curl

  Sources   Download

by Avatar shellus

25/11 2016

dev-master

9999999-dev

  Sources   Download

by Avatar shellus

25/11 2016

dev-dev-master

dev-dev-master

  Sources   Download

by Avatar shellus

25/11 2016

v1.0.1

1.0.1.0

  Sources   Download

by Avatar shellus

23/11 2016

v1.0.0

1.0.0.0

  Sources   Download

by Avatar shellus