ml/fgc-client

HTTPlug-conformant file_get_contents HTTP client

1.0.1 2016-01-03 18:17 UTC

This package is auto-updated.

Last update: 2024-10-25 21:16:54 UTC


README

Build Status Code Coverage

This is a HTTPlug-conformant HTTP client based on file_get_contents.

Installation

The easiest way to use fgc-client is to integrate it as a dependency in your project's composer.json file:

php composer.phar require ml/fgc-client ^1.0

Please note that HTTPlug hasn't released a stable version yet. Thus, for the time being, you need to set the minimum stability in your composer.json file to beta:

{
    ...
    "minimum-stability": "beta",
    "require": {
        ...
}

Usage

After having installed the desired dependencies

php composer.phar require guzzlehttp/psr7 ^1.0 php-http/message ^0.2

issuing an HTTP request is quite straightforward:

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();