Simple HTTP client without cURL dependency.
Install this package, your favorite psr-7 implementation and your favorite psr-17 implementation.
composer require webclient/webclient:^1.0
<?php
use Webclient\Http\Webclient;
use Psr\Http\Message\RequestInterface;
use Psr\Http\Message\ResponseFactoryInterface;
use Psr\Http\Message\StreamFactoryInterface;
/**
* @var ResponseFactoryInterface $responseFactory
* @var StreamFactoryInterface $streamFactory
*/
$http = new Webclient($responseFactory, $streamFactory);
/** @var RequestInterface $request */
$response = $http->sendRequest($request);
$code = $response->getStatusCode();
$phrase = $response->getReasonPhrase();
$headers = $response->getHeaders();
$someHeader = $response->getHeader('Content-Type');
$body = $response->getBody()->__toString();