PHP code example of rnr1721 / le7-http-client
1. Go to this page and download the library: Download rnr1721/le7-http-client library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
rnr1721 / le7-http-client example snippets
use Nyholm\Psr7\Factory\Psr17Factory;
use Core\HttpClient\HttpClientCurl;
use Core\HttpClient\HttpClientDefault;
// Create PSR factories. Nyholm realisation is a single factory to all
$psr17Factory = new Psr17Factory();
// Get Curl http client
$httpClientCurl = new HttpClientCurl(
$psr17Factory // ResponseFactoryInterface
)
// Or if need get PHP http client
$httpClientPhp = new HttpClientDefault(
$psr17Factory // ResponseFactoryInterface
)
// now we can use it:
$request = $psr17Factory->createRequest('GET', 'http://tnyholm.se');
$response = $httpClientCurl->sendRequest($request);