phyrexia/http
最新稳定版本:2.7.0
Composer 安装命令:
composer require phyrexia/http
包简介
PHP PSR-7 compatible HTTP client (using cURL)
README 文档
README
PHP PSR-7 compatible HTTP client (using cURL)
Requirements
- PHP >= 5.3
- PHP extension curl
- Composer psr/http-message ^1.0
- Composer guzzlehttp/psr7 ^1.0
Installation
Install directly via Composer:
$ composer require phyrexia/http
Basic Usage
<?php require 'vendor/autoload.php'; use Phyrexia\Http\Client as HttpClient; //HTTP GET to www.google.fr $response = HttpClient::get('http://www.google.fr'); //And now with a query string $response = HttpClient::get('http://www.google.fr', 'a=1&b=c'); //Query string in array format $response = HttpClient::get('http://www.google.fr', array('a' => 1, 'b' => 'c')); //An HTTP POST with some data $response = HttpClient::post('http://www.google.fr', array('user' => 'test', 'submit' => 1)); //You can also build an HttpClient object, and provide cURL options (::get, ::post and ::head support cURL options too) $client = new HttpClient('http://www.google.fr', 'GET', array(CURLOPT_CONNECTTIMEOUT => 2, CURLOPT_TIMEOUT => 5)); $response = $client->send(); //The response is a Response object, if you just want the body, you can cast it as a string $body = (string)HttpClient::get('http://www.google.fr');
统计信息
- 总下载量: 2.54k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 6
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-09-21