diff --git a/src/index.php b/src/index.php new file mode 100644 index 0000000..1939977 --- /dev/null +++ b/src/index.php @@ -0,0 +1,35 @@ +request('GET', 'https://api.github.com/repos/guzzle/guzzle'); +} catch (GuzzleException $e) { + echo $e->getMessage(); + return; +} + +echo $response->getStatusCode() . PHP_EOL; +echo $response->getHeaderLine('content-type') . PHP_EOL; +echo $response->getBody() . PHP_EOL; + +// asynchronous +$request = new Request('GET', 'https://httpbin.org'); + +$promise = $client + ->sendAsync($request) + ->then(function ($response) { + echo 'I completed! ' . $response->getBody(); + }); + +echo "before waiting for response" . PHP_EOL; + +$promise->wait(); + +echo "after waiting for response" . PHP_EOL; \ No newline at end of file