Skip to content

Commit 244761e

Browse files
committed
Updated readme
1 parent 9afcec3 commit 244761e

File tree

1 file changed

+34
-1
lines changed

1 file changed

+34
-1
lines changed

README.md

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<img src="https://avatars0.githubusercontent.com/u/76976189?s=140" alt="Semperton">
44
</a>
55
<h1>Semperton Proxy</h1>
6-
<p>Simple PHP proxy.</p>
6+
<p>Simple PSR-18 HTTP client based on PHP's native stream socket.</p>
77
//
88
</div>
99

@@ -17,3 +17,36 @@ Just use Composer:
1717
composer require semperton/proxy
1818
```
1919
Proxy requires PHP 7.1+
20+
21+
## Usage
22+
The client does not come with a PSR-17 request/response factory by itself.
23+
You have to provide one in the constructor.
24+
25+
```php
26+
use HttpSoft\Message\ResponseFactory;
27+
use Semperton\Proxy\Client;
28+
29+
$client new Client(
30+
new ResponseFactory(), // any PSR-17 compilant response factory
31+
5, // request timeout in secs
32+
$options, // array of stream context options
33+
4096 // buffer size used to read/write request body
34+
);
35+
```
36+
37+
The client exposes only one public method ```sendRequest```:
38+
```php
39+
use HttpSoft\Message\RequestFactory;
40+
use Psr\Http\Message\ResponseInterface;
41+
42+
$requestFactory = new RequestFactory();
43+
$request = $requestFactory->createRequest('GET', 'https://google.com');
44+
45+
$response = $client->sendRequest($request);
46+
47+
$response instanceof ResponseInterface // true
48+
49+
```
50+
51+
## Note
52+
This is just a very simple HTTP client for single requests. If you are going to do heavy API work (multiple asynchronous requests, body parsing, etc.), you should consider using ```guzzlehttp/guzzle``` or ```symfony/http-client```.

0 commit comments

Comments
 (0)