1. Go to this page and download the library: Download sunrise/http-client-curl 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/ */
sunrise / http-client-curl example snippets
use Sunrise\Http\Client\Curl\Client;
use Sunrise\Http\Factory\RequestFactory;
use Sunrise\Http\Factory\ResponseFactory;
$client = new Client(new ResponseFactory());
$request = (new RequestFactory)->createRequest('GET', 'http://php.net/');
$response = $client->sendRequest($request);
echo $response->getStatusCode(), PHP_EOL;
$requests = [
(new RequestFactory)->createRequest('GET', 'http://php.net/'),
(new RequestFactory)->createRequest('GET', 'http://php.net/'),
];
$client = new Client(new ResponseFactory());
$responses = $client->sendRequests(...$request);
foreach ($responses as $i => $response) {
// note that you can get the response's request by its index...
echo sprintf('%s => %d', $requests[$i]->getUri(), $response->getStatusCode()), PHP_EOL;
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.