1. Go to this page and download the library: Download rexlabs/hyper-http 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/ */
rexlabs / hyper-http example snippets
use Rexlabs\HyperHttp\Hyper;
$response = Hyper::get('http://openlibrary.org/subjects/love.json');
// The first book for 'love' is: Wuthering Heights
echo "The first book for '{$response->name}' is: {$response->works->first()->title}\n";
echo "Total works: {$response->works->count()} books\n";
use Rexlabs\HyperHttp\Hyper;
$response = Hyper::get('https://example.com/url');
echo 'Status Code: '.$response->getStatusCode()."\n";
echo (string)$response; // Output the response body
use Rexlabs\HyperHttp\Hyper;
// Fetch historical price via CryptoCompare's public API for Ethereum
$response = Hyper::get('https://min-api.cryptocompare.com/data/pricehistorical', [
'fsym' => 'ETH',
'tsyms' => 'BTC,USD',
'ts' => '1452680400',
]);
// Output prices
printf("ETH->USD: %s\n", $response->get('ETH.USD'));
printf("ETH->BTC: %s\n", $response->get('ETH.BTC'));
use Rexlabs\HyperHttp\Hyper;
use Rexlabs\Logger\CustomLogger;
$hyper = Hyper::make()
->setBaseUri('http://example.com/api/v1')
->setHeader('X-App-Identity', 'Some App')
->setHeader('X-Correlation-Id', '12345')
->setLogger(new CustomLogger);
use Rexlabs\HyperHttp\Client;
use GuzzleHttp\Client as GuzzleClient;
use Psr\Log\NullLogger;
$hyper = new Client(new GuzzleClient(), new NullLogger(), [
'base_uri' => 'http://example.com/api/v1',
'headers' => [
'X-App-Identity' => 'Some App',
],
]);
$response = $hyper->get('/messages');
use Rexlabs\HyperHttp\Hyper;
echo Hyper::get('https://example.com/api/v1/resources')
->getCurlRequest();
$obj = $response->toObject(); // Instance of Arraybject
Hyper::setDefaultConfig($config);
$client = Hyper::make($config);
Hyper::setDefaultLogger($logger);
$config = [
'log_curl' => true,
];
$config = [
'guzzle' => [
'verify' => false,
],
];
// Set for all clients
Hyper::setDefaultConfig($config);
// Set for one client
$client = Hyper::make($config);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.