|
1 | | -# HttpClient |
| 1 | +# Deprecation notice |
| 2 | + |
| 3 | +This package has now been migrated over to |
| 4 | +[react/http](https://github.com/reactphp/http) |
| 5 | +and only exists for BC reasons. |
| 6 | + |
| 7 | +```bash |
| 8 | +$ composer require react/http |
| 9 | +``` |
| 10 | + |
| 11 | +If you've previously used this package, upgrading may take a moment or two. |
| 12 | +The new API has been updated to use Promises and PSR-7 message abstractions. |
| 13 | +This means it's now more powerful and easier to use than ever: |
| 14 | + |
| 15 | +```php |
| 16 | +// old |
| 17 | +$client = new React\HttpClient\Client($loop); |
| 18 | +$request = $client->request('GET', 'https://example.com/'); |
| 19 | +$request->on('response', function ($response) { |
| 20 | + $response->on('data', function ($chunk) { |
| 21 | + echo $chunk; |
| 22 | + }); |
| 23 | +}); |
| 24 | +$request->end(); |
| 25 | + |
| 26 | +// new |
| 27 | +$browser = new React\Http\Browser($loop); |
| 28 | +$browser->get('https://example.com/')->then(function (Psr\Http\Message\ResponseInterface $response) { |
| 29 | + echo $response->getBody(); |
| 30 | +}); |
| 31 | +``` |
| 32 | + |
| 33 | +See [react/http](https://github.com/reactphp/http#client-usage) for more details. |
| 34 | + |
| 35 | +The below documentation applies to the last release of this package. |
| 36 | +Further development will take place in the updated |
| 37 | +[react/http](https://github.com/reactphp/http), |
| 38 | +so you're highly recommended to upgrade as soon as possible. |
| 39 | + |
| 40 | +# Deprecated HttpClient |
2 | 41 |
|
3 | 42 | [](https://travis-ci.org/reactphp/http-client) |
4 | 43 |
|
5 | 44 | Event-driven, streaming HTTP client for [ReactPHP](https://reactphp.org). |
6 | 45 |
|
7 | | -> Note that this is a very low-level HTTP client implementation that is currently |
8 | | - undergoing some major changes. In the meantime, we recommend using |
9 | | - [clue/reactphp-buzz](https://github.com/clue/reactphp-buzz) as a higher-level |
10 | | - HTTP client abstraction (which happens to build on top of this project). It |
11 | | - provides a Promise-based interface and common PSR-7 message abstraction which |
12 | | - makes getting started much easier. |
13 | | - |
14 | 46 | **Table of Contents** |
15 | 47 |
|
16 | 48 | * [Basic usage](#basic-usage) |
|
0 commit comments