1. Go to this page and download the library: Download pulkitjalan/requester 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/ */
use PulkitJalan\Requester\Requester;
use GuzzleHttp\Client as GuzzleClient;
$requester = new Requester(new GuzzleClient());
// simple get request
$requester->url('example.com')->get();
// retry 10 times, with a 1 second wait on a 503 error
$requester->url('example.com')->retry(10)->every(1000)->on([503])->get();
// disabling retry
$requester->url('example.com')->retry(false)->get();
// Create a post request
$response = $requester->url('example.com')->async(true)->get();
// Use the response asynchronously
$this->response = $response->then(function ($response) {
return $response->getBody();
});
// Use the response synchronously
$this->response = $response->getBody();
use PulkitJalan\Requester\Requester;
use GuzzleHttp\Client as GuzzleClient;
use Monolog\Logger;
use Monolog\Handler\StreamHandler;
// create a log channel
$log = new Logger('name');
$log->pushHandler(new StreamHandler('/path/to/your.log', Logger::INFO));
$requester = new Requester(new GuzzleClient());
$requester->addLogger($log);
// request and response logged to file
$requester->url('example.com')->get();
// Use the second param to update the format
$requester = new Requester(new GuzzleClient());
$requester->addLogger($log, 'DEBUG');
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.