ReactPHP HttpClient Adapter for Guzzle
PHP Makefile
Permalink
Failed to load latest commit information.
examples
src
tests Mocked response Aug 11, 2015
.dunitconfig
.dunitconfig-nightly Dunit and code sniffer Aug 10, 2015
.gitattributes
.gitignore Comitting composer.lock from now on Apr 19, 2015
.scrutinizer.yml
.travis.yml
CONTRIBUTING.md Create CONTRIBUTING.md Jul 12, 2015
LICENSE
Makefile Added missing dunit-nightly to make file Aug 11, 2015
README.md
composer.json
composer.lock Making sure we use http client 3.0.1 and up Nov 3, 2015
phpunit.xml.dist Testing foundation Apr 8, 2014

README.md

ReactGuzzle

Build Status Latest Stable Version Total Downloads Coverage Status License

ReactPHP HttpClient Adapter for Guzzle4, for Guzzle5 check ReactGuzzleRing and Guzzle6 check react-guzzle-psr7

Installation

To install via Composer, use the command below, it will automatically detect the latest version and bind it with ~.

composer require wyrihaximus/react-guzzle 

Basic Usage

<?php

require dirname(__DIR__) . '/vendor/autoload.php';

use GuzzleHttp\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();

See the examples directory for more ways to use this adapter.

Note about save_to

File I/O in react is blocking and doesn't always play well with certain event loops. So use save_to with caution as it will have a less then optimal performance.

License

Copyright 2014 Cees-Jan Kiewiet

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.