File tree Expand file tree Collapse file tree 1 file changed +40
-2
lines changed Expand file tree Collapse file tree 1 file changed +40
-2
lines changed Original file line number Diff line number Diff line change @@ -20,12 +20,50 @@ $ composer require php-http/curl-client
20
20
21
21
## Usage
22
22
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/ ) .
24
62
25
63
## Testing
26
64
27
65
``` bash
28
- $ phpunit
66
+ $ composer test
29
67
```
30
68
31
69
## Contributing
You can’t perform that action at this time.
0 commit comments