You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A `HTTPClientInterface` is usually invoked with a [`HTTPOptions`](https://github.com/chillerlan/php-httpinterface/blob/master/src/HTTPOptions.php) object as the first (optional) parameter,
59
+
and - depending on the client - followed by one or more optional [PSR-17](https://www.php-fig.org/psr/psr-17/) message factories.
60
+
```php
61
+
$options = new HTTPOptions([
62
+
'ca_info' => '/path/to/cacert.pem',
63
+
'user_agent' => 'my cool user agent 1.0',
64
+
]);
65
+
66
+
$http = new CurlClient($options, $myRequestFactory, $myResponseFactory);
67
+
```
68
+
You can now fire a request via the implemented [PSR-18](https://www.php-fig.org/psr/psr-18/) method `ClientInterface::sendRequest()`,
69
+
using an existing [PSR-7](https://www.php-fig.org/psr/psr-7/)`RequestInterface`...
70
+
```php
71
+
use chillerlan\HTTP\Psr7\Request;
72
+
73
+
$request = new Request('GET', 'https://www.example.com?foo=bar');
74
+
75
+
$http->sendRequest($request);
76
+
```
77
+
...or you can use the `HTTPClientInterface::request()` method, which creates a new request using the provided (if any) factories.
78
+
The `HTTPClientInterface` also provides constants for the HTTP methods via the [`RequestMethodInterface`](https://github.com/php-fig/http-message-util/blob/master/src/RequestMethodInterface.php).
0 commit comments