http요청 라이브러리인 Guzzle 나온지는 오래됨 10년은 된듯

PSR-7구현체 ㅇㅇ


Guzzle은 비동기/동기 둘다됨

요청하고 던질꺼면 Guzzle 쓰면될텐데

컴포저가 설치안되는 환경에서 돌리고 있어서 안쓰는지... ㄷ


심포니랑 라라벨에는 이미 Guzzle 이 들어가있음



<?php

$client = new GuzzleHttpClient();
$res = $client->request('GET', 'https://api.github.com/user', [
'auth' => ['user', 'pass']
]);
echo $res->getStatusCode();
// "200"
echo $res->getHeader('content-type')[0];
// 'application/json; charset=utf8'
echo $res->getBody();
// {"type":"User"...'

// Send an asynchronous request.
$request = new GuzzleHttpPsr7Request('GET', 'https://httpbin.org');
$promise = $client->sendAsync($request)->then(function ($response) {
echo 'I completed! ' . $response->getBody();
});
$promise->wait();



예제코드는 Guzzle 홈피에서 퍼옴