PHP code example of wyrihaximus / react-guzzle

1. Go to this page and download the library: Download wyrihaximus/react-guzzle 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/ */

    

wyrihaximus / react-guzzle example snippets




uzzleHttp\Client;
use GuzzleHttp\Message\Response;
use React\EventLoop\Factory;
use WyriHaximus\React\Guzzle\HttpClientAdapter;
use WyriHaximus\React\Guzzle\HttpClient\ProgressInterface;

// Create eventloop
$loop = Factory::create();

$client = new Client([
    'adapter' => new HttpClientAdapter($loop),
]);
$client->get('http://docs.guzzlephp.org/en/latest/')->then(function(Response $response) { // Success callback
    var_export($response);
}, function($event) { // Error callback
    var_export($event);
}, function(ProgressInterface $event) { // Progress callback
    var_export($event);
});

$loop->run();