1
- PHP Fetch
2
- =========
3
-
4
- A simple, type-safe, zero dependency port of the javascript ` fetch ` WebApi for PHP.
1
+ <h1 align =" center " >PHP Fetch</h1 >
5
2
3
+ <p align =" center " >A simple, type-safe, zero dependency port of the javascript fetch WebApi for PHP.</p >
6
4
7
5
<h3 align =" center " >
8
6
<img style="alignment: center" src="https://media0.giphy.com/media/xlYKItjhiDsY/giphy.gif?cid=ecf05e474io66b5jt2mrufubg3otjzq26qgtqd0cb0w71fiu&rid=giphy.gif"/>
@@ -63,9 +61,12 @@ while (($chunk = $response->body()->read()) !== null) {
63
61
64
62
At the moment, the only options supported are:
65
63
66
- - ` method ` : Sets the request method
67
- - ` body ` : The request body. It can be a ` resource ` , a ` string ` or ` null ` .
68
- - ` headers ` : An associative array of header names and values.
64
+ - ` method (string) ` : Sets the request method
65
+ - ` body (resource|string) ` : The request body.
66
+ - ` headers (array<string|string>) ` : An associative array of header names and values.
67
+ - ` follow_redirects (bool) ` : Whether to follow redirects or not. Default is ` true ` .
68
+ - ` protocol_version (string) ` : The http protocol version to use. Default is ` 1.1 ` .
69
+ - ` max_redirects (int) ` : The number of times you allow redirecting. Default is ` 20 ` .
69
70
70
71
### Getting response information
71
72
@@ -85,7 +86,7 @@ echo $response->status()->reasonPhrase(); // OK
85
86
echo $response->headers()->has('content-type'); // true
86
87
echo $response->headers()->contains('content-type', 'html'); // true
87
88
echo $response->headers()->get('content-type'); // text/html;charset=utf-8
88
- echo $response->body()->read('' ); // Outputs some bytes from the response body
89
+ echo $response->body()->read(); // Outputs some bytes from the response body
89
90
```
90
91
91
92
### Exception Handling
0 commit comments