1. Go to this page and download the library: Download zelenin/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/ */
zelenin / http-client example snippets
use Zelenin\HttpClient\ClientFactory;
use Zend\Diactoros\Request;
use Zend\Diactoros\Uri;
$client = (new ClientFactory())->create();
$request = new Request(new Uri('https://example.com/'), 'GET');
$response = $client->sendRequest($request);
use Zelenin\HttpClient\Middleware\Cookie\CookieRequest;
use Zelenin\HttpClient\Middleware\Cookie\CookieResponse;
use Zelenin\HttpClient\Middleware\Cookie\FileStorage;
use Zelenin\HttpClient\Middleware\Deflate;
use Zelenin\HttpClient\Middleware\UserAgent;
use Zelenin\HttpClient\MiddlewareClient;
use Zelenin\HttpClient\RequestConfig;
use Zelenin\HttpClient\Transport\CurlTransport;
use Zend\Diactoros\Request;
use Zend\Diactoros\ResponseFactory;
use Zend\Diactoros\StreamFactory;
use Zend\Diactoros\Uri;
$streamFactory = new StreamFactory();
$responseFactory = new ResponseFactory();
$cookieStorage = new FileStorage('/tmp/http-client/cookies.storage');
$client = new MiddlewareClient([
new CookieRequest($cookieStorage),
new UserAgent(sprintf('HttpClient PHP/%s', PHP_VERSION)),
new Deflate($streamFactory),
new CookieResponse($cookieStorage),
new CurlTransport($streamFactory, $responseFactory, new RequestConfig()),
], $responseFactory);
$request = new Request(new Uri('https://example.com/'), 'GET');
$response = $client->sendRequest($request);
php composer.phar
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.