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
HttpExceptionthrows byCurl::request()for requests except HEAD when returned response status not in range 200 ... 300 codes.
Links
统计信息
- 总下载量: 40
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: GPL-3.0
- 更新时间: 2015-10-23