定制 skoro/curl 二次开发

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

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

skoro/curl

最新稳定版本:0.2.2

Composer 安装命令:

composer require skoro/curl

包简介

Object oriented wrapper for curl functions.

README 文档

README

Object oriented wrapper for curl functions. Wrappers for curl and curl_multi functions are available.

Installation

The preferred way to install this extension is through composer.

Either run

php composer.phar require --prefer-dist skoro/curl "*"

or add

"skoro/curl": "*"

to the require section of your composer.json file.

Usage

Once the extension is installed, simply use it in your code by :

// Include composer autoload script.
require 'vendor/autoload.php';

use skoro\curl\Curl;

// Simple GET request.
$content = Curl::get('google.com');

// HEAD request
$curl = new Curl('google.com', 'HEAD');
$body = $curl->request(); // Returns response with headers.
         $curl->getResponse(); // Returns "raw" response.
         $curl->getResponseHeaders(); // Returns array of headers.
}

Curl multi usage:

require 'vendor/autoload.php';

use skoro\curl\Multi;
use skoro\curl\Curl;

$multi = new Multi();
// Attach curl instances and run them.
$multi->add(new Curl('google.com', 'HEAD'))
      ->add(new Curl('microsoft.com', 'HEAD'))
      ->add(new Curl('amazon.com'))
      ->run();
// Get responses.
foreach ($multi as $curl) {
    var_dump($curl->getResponse());
}

Exceptions

  • HttpException throws by Curl::request() for requests except HEAD when returned response status not in range 200 ... 300 codes.

Links

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: GPL-3.0
  • 更新时间: 2015-10-23