Skip to content

Commit cc3fb03

Browse files
committed
Add usage section in the README
Fix #1
1 parent cdf889a commit cc3fb03

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,29 @@ $ composer require php-http/react-adapter
2020

2121
## Usage
2222

23+
The `ReactHttpAdapter` class need a [message factory](https://github.com/php-http/message-factory) in order to work:
24+
25+
```php
26+
$client = new Http\Adapter\ReactHttpAdapter($messageFactory);
27+
```
28+
29+
For more control, it can also be configured with a specific `React\EventLoop\LoopInterface` and / or a specific `React\HttpClient\Client`:
30+
31+
```php
32+
$loop = Http\Adapter\ReactFactory::buildEventLoop();
33+
$client = new Http\Adapter\ReactHttpAdapter($messageFactory, $loop);
34+
35+
//or
36+
37+
$reactClient = Http\Adapter\ReactFactory::buildHttpClient($loop);
38+
$client = new Http\Adapter\ReactHttpAdapter(
39+
$messageFactory,
40+
$loop,
41+
$reactClient
42+
);
43+
```
44+
45+
If you don't want to use the `Http\Adapter\ReactFactory` to build instances you must rely on React documentation on Github: https://github.com/reactphp/http-client#example
2346

2447
## Testing
2548

0 commit comments

Comments
 (0)