Just use Composer:
composer require semperton/proxy
Proxy requires PHP 7.1+
The client does not come with a PSR-17 request/response factory by itself. You have to provide one in the constructor.
useHttpSoft\Message\ResponseFactory;
useSemperton\Proxy\Client;
$client new Client(
newResponseFactory(), // any PSR-17 compilant response factory5, // request timeout in secs$options, // array of stream context options4096// buffer size used to read/write request body
);The client exposes only one public method sendRequest:
useHttpSoft\Message\RequestFactory;
usePsr\Http\Message\ResponseInterface;
$requestFactory = newRequestFactory();
$request = $requestFactory->createRequest('GET', 'https://google.com');
$response = $client->sendRequest($request);
$responseinstanceof ResponseInterface // trueThis is just a very simple HTTP client for single requests. If you are going to do heavy API work (multiple asynchronous requests, body parsing, etc.), you should consider using guzzlehttp/guzzle or symfony/http-client.