Handles server-to-server connections.
Refer to vinelab/http on packagist.org for composer installation instructions.
Edit app.php and add 'Vinelab\Http\HttpServiceProvider',
to the 'providers'
array.
It will automatically alias itself as HttClient so no need to aslias it in your app.php unless you would like to customize it. In that case edit your 'aliases' in app.php adding 'MyHttp' => 'Vinelab\Http\Facades\Client',
$response = HttpClient::get('http://example.org');
// raw content
$response->content();
$request = [
'url' => 'http://somehost.net/something',
'params' => [
'id' => '12350ME1D',
'lang' => 'en-us',
'format' => 'rss_200'
]
];
$response = HttpClient::get($request);
// raw content
$response->content();
// in case of json
$response->json();
// XML
$response->xml();
$request = [
'url' => 'http://somehost.net/somewhere',
'params' => [
'id' => '12350ME1D',
'lang' => 'en-us',
'format' => 'rss_200'
]
];
$response = HttpClient::post($request);
// raw content
$response->content();
// in case of json
$response->json();
// XML
$response->xml();
It is pretty much the same process with different HTTP Verbs. Supports
GET, POST, PUT, DELETE, PATCH, OPTIONS, HEAD
- Improve tests to include testing all the methods of response (like statusCode...)
- Include tests for handling bad data / errors
- Improve tests to include testing for all HTTP Verbs
- Improve support for XML requests (left till needed)