The Http Client officially recommends using saber and Guzzle to no longer recreate the wheels.

Saber

Swoole's officially packaged Http client library has been used in several large projects.

installation

 composer require swlib/saber 

use

 SaberGM::get('http://httpbin.org/get');
SaberGM::delete('http://httpbin.org/delete');
SaberGM::post('http://httpbin.org/post', ['foo' => 'bar']);
SaberGM::put('http://httpbin.org/put', ['foo' => 'bar']);
SaberGM::patch('http://httpbin.org/patch', ['foo' => 'bar']); 

Guzzle

Guzzle's old HTTP wrapper library, many dependencies are encapsulated.

Swoole version must be 4.4 or above

installation

 composer require guzzlehttp/guzzle 

use

 
$client = new \GuzzleHttp\Client();
$response = $client->request('GET', 'https://api.github.com/repos/guzzle/guzzle');

echo $response->getStatusCode(); # 200
echo $response->getHeaderLine('content-type'); # 'application/json; charset=utf8'
echo $response->getBody(); # '{"id": 1420053, "name": "guzzle", ...}' 
/docs/2.x/en/http-server/http.html
progress-bar