File tree Expand file tree Collapse file tree 1 file changed +23
-0
lines changed
Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change 1+ <center >
2+ ![ ] ( https://img.shields.io/github/last-commit/Athlon1600/php-curl-client.svg )
3+ </center >
4+
15# PHP Curl Client
26
37A very simple curl client - less than 100 lines. Perfect for being a base class.
@@ -14,6 +18,8 @@ composer require athlon1600/php-curl-client
1418use Curl\Client;
1519
1620$client = new Client();
21+
22+ // returns standardized Response object no matter what
1723$response = $client->get('https://stackoverflow.com');
1824
1925// 200
@@ -29,6 +35,23 @@ $error = $response->error;
2935$info = $response->info;
3036```
3137
38+ Works with POST requests too:
39+
40+ ``` php
41+ $client->post('http://httpbin.org/post', ['username' => 'bob', 'password' => 'test']);
42+ ```
43+
44+ or you can issue a completely customized request:
45+
46+ ``` php
47+ $client->request('GET', 'https://www.whatismyip.com/', null, [
48+ 'User-Agent' => 'Mozilla/5.0 (iPhone; CPU iPhone OS 12_0 like Mac OS X)'
49+ ], [
50+ CURLOPT_PROXY => '127.0.0.1:8080',
51+ CURLOPT_TIMEOUT => 10
52+ ]);
53+ ```
54+
3255## TODO
3356
3457- make PSR-7 and PSR-18 compatible
You can’t perform that action at this time.
0 commit comments