Created
September 9, 2015 22:37
-
-
Save mtdowling/bafd8011a7a641974601 to your computer and use it in GitHub Desktop.
React, Guzzle, and AWS SDK for PHP integration
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require 'vendor/autoload.php'; | |
use GuzzleHttp\Client; | |
use GuzzleHttp\HandlerStack; | |
use GuzzleHttp\Psr7\Response; | |
use React\EventLoop\Factory; | |
use WyriHaximus\React\GuzzlePsr7\HttpClientAdapter; | |
$loop = Factory::create(); | |
$reactHandler = new HttpClientAdapter($loop); | |
$handlerStack = HandlerStack::create($reactHandler); | |
$guzzleClient = new Client(['handler' => $handlerStack]); | |
$guzzleClient->getAsync('http://google.com/')->then(function ($response) { | |
var_export($response); | |
}); | |
/* | |
// Use React with the AWS SDK | |
use Aws\Handler\GuzzleV6\GuzzleHandler; | |
$awsHandler = new GuzzleHandler($guzzleClient); | |
$sdk = new Aws\Sdk(['http_handler' => $awsHandler]); | |
$s3 = $sdk->createS3(['version' => 'latest', 'region' => 'us-east-1']); | |
$s3->getObjectAsync(['Bucket' => 't1234', 'Key' => 'test']) | |
->then( | |
function ($result) { echo $result; }, | |
function ($reason) { echo $reason; } | |
); | |
*/ | |
$loop->run(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment