simple promise (xdebug things)
This commit is contained in:
parent
522b690885
commit
9be9f6f096
|
@ -1,2 +1,3 @@
|
|||
vendor/
|
||||
composer.lock
|
||||
.vscode
|
|
@ -9,10 +9,7 @@ Lib\plain();
|
|||
Lib\printf('https://sergio.am/code/www-tests');
|
||||
|
||||
use GuzzleHttp\Client;
|
||||
use GuzzleHttp\Promise;
|
||||
use GuzzleHttp\Pool;
|
||||
use GuzzleHttp\Psr7\Response;
|
||||
use GuzzleHttp\Promise\EachPromise;
|
||||
|
||||
Lib\printf('client');
|
||||
|
||||
|
|
|
@ -0,0 +1,37 @@
|
|||
<?php
|
||||
|
||||
require_once(dirname(__FILE__) .'/vendor/autoload.php');
|
||||
|
||||
// lib.php, helper functions
|
||||
Lib\plain();
|
||||
Lib\printf('https://sergio.am/code/www-tests');
|
||||
|
||||
use GuzzleHttp\Client;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use GuzzleHttp\Exception\RequestException;
|
||||
|
||||
Lib\printf('client');
|
||||
|
||||
$client = new Client(['base_uri' => 'http://httpbin.org/']);
|
||||
|
||||
Lib\printf('promise');
|
||||
|
||||
$promise = $client->getAsync('/get');
|
||||
|
||||
Lib\printf('then');
|
||||
|
||||
$promise->then(
|
||||
function (ResponseInterface $res) {
|
||||
echo $res->getStatusCode() . "\n";
|
||||
},
|
||||
function (RequestException $e) {
|
||||
echo $e->getMessage() . "\n";
|
||||
echo $e->getRequest()->getMethod();
|
||||
}
|
||||
);
|
||||
|
||||
Lib\printf('wait');
|
||||
|
||||
$promise->wait();
|
||||
|
||||
Lib\printf('end');
|
Loading…
Reference in New Issue