1. Go to this page and download the library: Download xd/async-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/ */
xd / async-http example snippets
//requsting
$req = AsyncHttp::get("http://192.168.88.2?sleepTime=3")->request();
//do somthing...
//get response
$response = $req->getResponse();
//get body
$resBody = $response->body;
//get http status code
$httpStatusCode = $response->statusCode;
//get response all header
$headers = $response->headers;
//get one header
$header = $response->getHeader('Server');
//requesting by x-www-form-urlencode
$postData = ['sleepTime' => 3];
$req = AsyncHttp::post("http://192.168.88.2", $postData)->request();
//requesting by raw JSON
$postData = json_encode(['sleepTime' => 1]);
$req2 = AsyncHttp::post("http://192.168.88.2", $postData)->request();
//requesting by raw XML
$req2 = AsyncHttp::post("http://192.168.88.2", $xmlDataStr)
->addHeader("Content-Type":"application/xml")->request();
//do somthing...
//get response
$body1 = $req->getResponse()->body;
$body2 = $req2->getResponse()->body;
$body3 = $req3->getResponse()->body;