PHP code example of choval / reactphp-curl-proc

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

    

choval / reactphp-curl-proc example snippets


use choval\React\Curl;
use choval\React\CurlResponse;

$loop = React\EventLoop\Factory::create();
$curl = new Curl($loop);

$curl->get('http://google.com/')
  ->then(function(CurlResponse $resp) {
    echo $resp->getBody();
  })
  ->otherwise(function(Exception $e) {
    echo 'ERROR: '.$e->getMessage().PHP_EOL;
  });