PHP code example of larium / http-client

1. Go to this page and download the library: Download larium/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/ */

    

larium / http-client example snippets






use Larium\Http\Client;
use Http\Discovery\Psr17FactoryDiscovery;
use Psr\Http\Client\ClientExceptionInterface;

$request = Psr17FactoryDiscovery::findRequestFactory()->createRequest('GET', 'http://www.example.com');
$client = new Client();
try {
	$response = $client->sendRequest($request);
	# Response is a Psr\Http\Message\ResponseInterface instance implementation.
} catch (ClientExceptionInterface $e) {
	//Resolve exception from client.
}