Skip to content

Commit 0e7c55d

Browse files
committed
Create documentation (closes #5).
1 parent 04570a6 commit 0e7c55d

File tree

1 file changed

+40
-2
lines changed

1 file changed

+40
-2
lines changed

README.md

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,50 @@ $ composer require php-http/curl-client
2020

2121
## Usage
2222

23-
TODO
23+
### Using [php-http/discovery](https://packagist.org/packages/php-http/discovery):
24+
25+
```php
26+
use Http\Client\HttpClient;
27+
use Http\Curl\CurlHttpClient;
28+
use Http\Discovery\MessageFactory\GuzzleMessageFactory;
29+
use Http\Discovery\StreamFactory\GuzzleStreamFactory;
30+
31+
$messageFactory = new GuzzleMessageFactory();
32+
$client = new CurlHttpClient($messageFactory, new GuzzleStreamFactory());
33+
34+
$request = $messageFactory->createRequest('GET', 'http://example.com/);
35+
$response = $client->sendRequest($request);
36+
37+
```
38+
39+
### Configuring client
40+
41+
You can use [cURL options](http://php.net/curl_setopt) to configure CurlHttpClient:
42+
43+
```php
44+
use Http\Client\HttpClient;
45+
use Http\Curl\CurlHttpClient;
46+
use Http\Discovery\MessageFactory\GuzzleMessageFactory;
47+
use Http\Discovery\StreamFactory\GuzzleStreamFactory;
48+
49+
$options = [
50+
CURLOPT_CONNECTTIMEOUT => 10, // The number of seconds to wait while trying to connect.
51+
CURLOPT_SSL_VERIFYPEER => false // Stop cURL from verifying the peer's certificate
52+
];
53+
$client = new CurlHttpClient(new GuzzleMessageFactory(), new GuzzleStreamFactory(), $options);
54+
```
55+
56+
Keep in mind that CurlHttpClient can overwrite some options like `CURLOPT_RETURNTRANSFER` or
57+
`CURLOPT_FOLLOWLOCATION`.
58+
59+
## Documentation
60+
61+
Please see the [official documentation](http://php-http.readthedocs.org/en/latest/).
2462

2563
## Testing
2664

2765
``` bash
28-
$ phpunit
66+
$ composer test
2967
```
3068

3169
## Contributing

0 commit comments

Comments
 (0)