PHP code example of jdriscoll / curl-psr

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

    

jdriscoll / curl-psr example snippets


    $handler = new \CurlPsr\Handler();
    $response = $handler->run(
        $request->withUri(
            $request->getUri()
                ->withPath("/")
                ->withHost("example.org")
                ->withScheme("http")
                ->withPort(80)
        ),
        true,
        10000
    );

    $handler = new \CurlPsr\Handler();
    $responses = $handler->withTimeout(10000)->runSimple(
        $request1,
        $request2
    );
    foreach($responses as $k => $response) {
        if($response->getBody()->getSize()) {
            echo "" . $response->getUri();
            echo "" . $response->getBody();
        }
    }

    $handler = new \CurlPsr\Handler();
    $responses = $handler->withTimeout(10000)->runMap([
        "a" => $request1,
        "b" => $request2
    ]);
    foreach($responses as $k => $response) {
        if($response->getBody()->getSize()) {
            echo "" . $response->getUri();
            echo "" . $response->getBody();
        }
    }