rokde / http-client
This package is abandoned and no longer maintained.
No replacement package was suggested.
A http client library without any dependencies. Just vanilla php.
1.1.0
2019-03-14 16:18 UTC
Requires
- php: ^7.1
Requires (Dev)
- phpunit/phpunit: ^7.2
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
This http client library does not have any dependencies like curl or guzzle. It uses plain php functions to handle the most common http requests.
Installation
composer require rokde/http-client
Usage
You have two options
- Use the helper function
http() - Use the full-blown class stack provided by the package
I recommend the use of the http() function to keep the packages purpose in mind: simplicity.
Using http()
// GET (get from uri) /** @var string $response */ $response = http('https://httpbin.org/get'); // POST (post data to uri) /** @var \Rokde\HttpClient\Response $response */ $response = http()->post(['data' => 'value'], 'https://httpbin.org/post');
Using the class version
$client = new \Rokde\HttpClient\Client(); $request = new \Rokde\HttpClient\Request('https://httpbin.org/get', 'GET', [ 'accept' => 'application/json', 'x-verify-test' => 'true', ]); $response = $client->send($request); if ($response->isOk()) { $resultString = $response->content(); }
Further usage examples can be found at the /tests folder of this package.
Testing
Run the tests with:
composer test