1. Go to this page and download the library: Download subtlephp/middlewares 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/ */
subtlephp / middlewares example snippets
use GuzzleHttp\HandlerStack;
use GuzzleHttp\Middleware;
use SubtlePHP\Middlewares\Guzzle\Retry;
use SubtlePHP\Middlewares\Guzzle\UriReplacer;
use SubtlePHP\Middlewares\Guzzle\Logger;
use GuzzleHttp\Client;
use GuzzleHttp\Psr7\Request;
$handlerStack = new HandlerStack();
$maxRetryTimes = 2;
$delay = 100;
$retryMiddleware = Middleware::retry(Retry::decider($maxRetryTimes), Retry::delay($delay));
$middlewares = [
new UriReplacer(),
new Logger(),
$retryMiddleware,
];
$handlerStack->push($retryMiddleware);
$base_uri = 'http://gank.io';
$pattern = '/api/data/Android/{per_page}/{page}';
$client = new Client(['base_uri' => $base_uri, 'handler' => $handlerStack, [
'attributes' => [
'page' => 1,
'per_page' => 10,
],
]]);
$request = new Request('GET', $pattern);
$response = $client->send($request);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.