mechta-market/php-http-client

There is no license information available for the latest version (1.0.2) of this package.

1.0.2 2024-09-04 10:09 UTC

This package is auto-updated.

Last update: 2025-03-04 11:11:07 UTC


README

GitHub Actions Workflow Status Packagist Downloads

Установка

composer require mechta-market/php-http-client

Примеры:

GET запрос

$httpClient = new HttpClient();
$response = $httpClient->get("example.org");

var_dump($response->successful());

GET запрос с параметрами

$httpClient = new HttpClient();
$httpClient->withQueryParameters(["foo" => "bar", "test" => "value"]);
$response = $httpClient->get("example.org");

var_dump($response->successful());

POST запрос

$httpClient = new HttpClient();
$data = ["foo" => "bar"];
$response = $httpClient->post("example.org", $data);

var_dump($response->successful());

POST запрос с body

$httpClient = new HttpClient();
$data = ["foo" => "bar"];
$httpClient->withBody($data);

$response = $httpClient->post("example.org");

Bearer token

$httpClient = new HttpClient();
$httpClient->withToken("random_string_token_value");

$response = $httpClient->get("example.org");

Basic auth

$httpClient = new HttpClient();
$httpClient->withBasicAuth("user", "random_string_token_value");

$response = $httpClient->get("example.org");