-
Notifications
You must be signed in to change notification settings - Fork 0
/
example.php
32 lines (22 loc) · 900 Bytes
/
example.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<?php
/**
* SPDX-FileCopyrightText: © 2024 Christoph Zysik [email protected]
* SPDX-License-Identifier: BSD-3-Clause
*/
declare(strict_types=1);
use Ztk\HttpClient\Content\JsonProcessor;
use Ztk\HttpClient\Model\Request;
require 'vendor/autoload.php';
$logger = new Monolog\Logger('logger');
$haproxy_protocol_would_be_nice = new Ztk\HttpClient\Option\ResolveOption(['example.com' => '127.0.0.1']);
$json_processor = new JsonProcessor();
$json_processor->setLogger($logger);
$http_client = new Ztk\HttpClient\Client();
$http_client->setLogger($logger);
$http_client->useHttpClient(new Symfony\Component\HttpClient\CurlHttpClient());
$http_client->useOption($haproxy_protocol_would_be_nice);
$http_client->useProcessor($json_processor);
/** @noinspection HttpUrlsUsage */
$request = new Request('GET', 'https://example.com');
$response = $http_client->request($request);
print_r($response);