dawidlisiecki / http-client
Http client
dev-master
2023-05-11 18:09 UTC
Requires
- php: ^8.1
- ext-curl: *
- nyholm/psr7: ^1.5
- phpunit/phpunit: ^10.0
This package is not auto-updated.
Last update: 2025-01-03 01:56:49 UTC
README
Easy to use http client library.
Installation
composer require dawidlisiecki/http-client
Setup
use DawidLisiecki\Client;
$client = Client::withoutAuth('http://example.com');
$client->get('/endpoint');
Client class
Without authorization
$client = Client::withoutAuth('http://example.com');
Basic authorization
$client = Client::withBasicAuth('http://example.com', 'username', 'password');
JWT authorization
$client = Client::withJWTAuth('http://example.com', 'token');
Api key authorization
$client = Client::withAPIKey('http://example.com', 'api_key_name', 'api_key_value');
Client methods
GET
$client->get('/endpoint', $data = []);
POST
$client->post('/endpoint', $data = []);
PUT
$client->put('/endpoint', $data = []);
DELETE
$client->delete('/endpoint', $data = []);
Arguments
Params | Type | Required |
---|---|---|
endpoint | string | yes |
data | array | no |