PHP code example of guzzlehttp / psr7

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

    

guzzlehttp / psr7 example snippets


use GuzzleHttp\Psr7\Request;
use GuzzleHttp\Psr7\Response;
use GuzzleHttp\Psr7\Utils;

$request = new Request('GET', 'https://example.com/api');
$response = new Response(200, ['Content-Type' => 'text/plain'], 'OK');
$stream = Utils::streamFor('request or response body');

echo $request->getMethod();
echo $response->getStatusCode();
echo $stream;

$request = $request->withHeader('Accept', 'application/json');