larium/http-client
Composer 安装命令:
composer require larium/http-client
包简介
An http client implemention compatible with psr-7 http message.
README 文档
README
An http client wrapping curl php extension, compatible with PSR-7 Http Message interfaces.
Installation
You can install this library using Composer
Composer from command line
In root directory of your project run through a console:
$ composer require "larium/http-client":"~1.0"
Composer from composer.json
Include require line in your composer.json file
{
"require": {
"larium/http-client": "~1.0"
}
}
and run from console in the root directory of your project:
$ composer update
Set up
After installation you must require autoload file from composer in to your boot php script.
<?php require_once 'vendor/autoload.php';
Basic usage
Using message factory discovery
You can use factory discovery to find any Request class that implements PSR-7 HTTP Message interfaces, to create the Request instance.
<?php use Larium\Http\Client; use Http\Discovery\Psr17FactoryDiscovery; use Psr\Http\Client\ClientExceptionInterface; $request = Psr17FactoryDiscovery::findRequestFactory()->createRequest('GET', 'http://www.example.com'); $client = new Client(); try { $response = $client->sendRequest($request); # Response is a Psr\Http\Message\ResponseInterface instance implementation. } catch (ClientExceptionInterface $e) { //Resolve exception from client. }
统计信息
- 总下载量: 991
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 2
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-11-22