saxulum / saxulum-http-client-interface
Saxulum Http Client Interface
Installs: 2 566
Dependents: 8
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
Requires
- php: >=5.3
Requires (Dev)
- phpunit/phpunit: ~4.0
This package is not auto-updated.
Last update: 2020-09-22 19:08:05 UTC
README
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
- saxulum-http-client-adapter-buzz a kriswallsmith/buzz adapter
- saxulum-http-client-adapter-joomla a joomla/http adapter
- saxulum-http-client-adapter-guzzle a guzzle/guzzle adapter
- saxulum-http-client-adapter-vinelab a vinelab/http adapter
- saxulum-http-client-adapter-zend a zendframework/zend-http adapter