PHP code example of initphp / http-client

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

    

initphp / http-client example snippets


> // Before
> use InitPHP\HTTPClient\Client;
> use InitPHP\HTTP\Request;
>
> $client   = new Client(['timeout' => 0]);
> $request  = new Request('GET', 'https://example.com');
> $response = $client->sendRequest($request);
>
> // After
> use InitPHP\HTTP\Client\Client;
> use InitPHP\HTTP\Message\Request;
>
> $client   = new Client();
> $request  = new Request('GET', 'https://example.com');
> $response = $client->sendRequest($request);
> 


use InitPHP\HTTPClient\Client;

/** @var \Psr\Http\Client\ClientInterface $client */
$client = new Client();

/** @var \Psr\Http\Message\RequestInterface $request */
$request = new \InitPHP\HTTP\Request('GET', 'https://www.example.com');

/** @var \Psr\Http\Message\ResponseInterface $response */
$response = $client->sendRequest($request);