Skip to content

Simple async HTTP client library for fetching URLs, talking to RESTful APIs, downloading files, following redirects etc. built upon React PHP

License

Notifications You must be signed in to change notification settings

khanhtq/php-buzz-react

 
 

Repository files navigation

clue/buzz-react Build Status

Simple async HTTP client for concurrently interacting with multiple HTTP servers, fetching URLs, talking to RESTful APIs, downloading files, following redirects etc. all at the same time.

This library is heavily inspired by the great kriswallsmith/Buzz project. However, instead of blocking on each request, it relies on React PHP's EventLoop to process multiple requests in parallel.

React PHP also provides the package react/http-client which provides a streaming HTTP client implementation. That package is ideally suited for accessing streaming APIs or processing huge requests, but requires quite a bit of boilerplate code if all you want to do is to access a normal website or your average RESTful API.

As such, this projects aims at providing a higher level API that is easy to use in order to process multiple HTTP requests concurrently without having to mess with most of the low level details of the underlying react/http-client.

Note: This project is in beta stage! Feel free to report any issues you encounter.

Quickstart example

Once installed, you can use the following code to access a HTTP webserver and send some simple HTTP GET requests:

$client = new Browser($loop);

$client->get('http://www.google.com/')->then(function (Response $result) {
    var_dump($result->getHeaders(), $result->getBody());
});

$loop->run();

See also the examples.

Usage

Via SOCKS server

You can also establish your outgoing connections through a SOCKS proxy server by adding a dependency to clue/socks-react. See the SOCKS example.

Install

The recommended way to install this library is through composer. New to composer?

{
    "require": {
        "clue/buzz-react": "0.1.*"
    }
}

License

MIT

About

Simple async HTTP client library for fetching URLs, talking to RESTful APIs, downloading files, following redirects etc. built upon React PHP

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 100.0%