saxulum/saxulum-http-client-interface

This package is abandoned and no longer maintained. No replacement package was suggested.

Saxulum Http Client Interface

1.5 2014-11-04 06:53 UTC

README

Build Status Total Downloads Latest Stable Version Scrutinizer Code Quality

Features

  • Provides a simple http client interface
  • Provides a simple request and response object
  • Provides a header converter

Requirements

  • PHP 5.3+

Installation

Through Composer as saxulum/saxulum-http-client-interface.

Within a library/bundle

{
    "require": {
        "saxulum/saxulum-http-client-interface": "~1.0",
        "saxulum/saxulum-http-client-adapter": "~1.0"
    }
}

Within a project

Replace saxulum/saxulum-http-client-adapter-buzz with the adapter you like to use.

{
    "require": {
        "saxulum/saxulum-http-client-interface": "~1.0",
        "saxulum/saxulum-http-client-adapter-buzz": "~1.0"
    }
}

Usage

$httpClient = new MyHttpClientImplementation;
$response = $httpClient->request(new Request(
    '1.1',
    Request::METHOD_GET,
    'http://en.wikipedia.org',
    array(
        'Connection' => 'close',
    )
));

Implement

To implement this interface, you need a existing http client and write an adapter for it or use an existing one.

<?php

namespace Saxulum\HttpClient;

interface HttpClientInterface
{
    /**
     * @param  Request  $request
     * @return Response
     */
    public function request(Request $request);
}

Add the following to your adapter composer.json

{
    "provide": {
        "saxulum/saxulum-http-client-adapter": "1.0"
    }
}

Implementations