ml / fgc-client
符合HTTPlug规范的file_get_contents HTTP客户端
1.0.1
2016-01-03 18:17 UTC
Requires
- php: >=5.4
- php-http/httplug: ^1.0.0-beta
- php-http/message-factory: ^1.0
Requires (Dev)
- guzzlehttp/psr7: ^1.0
- php-http/adapter-integration-tests: dev-master
- php-http/message: ^0.2
- phpunit/phpunit: ^4.8
Provides
This package is auto-updated.
Last update: 2024-08-25 20:57:26 UTC
README
这是一个基于file_get_contents
的HTTPlug规范HTTP客户端。
安装
使用fgc-client
最简单的方式是将它作为依赖项集成到项目的composer.json文件中
php composer.phar require ml/fgc-client ^1.0
请注意,HTTPlug尚未发布稳定版本。因此,目前您需要在composer.json
文件中将最小稳定性设置为beta
{
...
"minimum-stability": "beta",
"require": {
...
}
使用方法
在安装所需的依赖项后
php composer.phar require guzzlehttp/psr7 ^1.0 php-http/message ^0.2
发起HTTP请求非常简单
require_once('vendor/autoload.php'); use Http\Message\MessageFactory\GuzzleMessageFactory; use Http\Message\StreamFactory\GuzzleStreamFactory; use ML\FgcClient\FgcHttpClient; $messageFactory = new GuzzleMessageFactory(); $client = new FgcHttpClient($messageFactory, new GuzzleStreamFactory()); $request = $messageFactory->createRequest('GET', 'http://example.com/'); $response = $client->sendRequest($request); echo $response->getStatusCode();