### PHPUnit VCRClient Setup with UseVcrClient Trait Source: https://github.com/phpro/http-tools/blob/v2.x/README.md An example of configuring a VCR client for PHPUnit tests using the `UseVcrClient` trait. This allows for recording and replaying HTTP requests, enabling tests to run with real data or recorded fixtures. ```php client = AutoDiscoveredClientFactory::create([ ...$this->useRecording(FIXTURES_DIR, new PathNamingStrategy()) ]); } } ``` -------------------------------- ### PHPUnit MockClient Setup with UseMockClient Trait Source: https://github.com/phpro/http-tools/blob/v2.x/README.md This PHP example shows how to set up a mock HTTP client in a PHPUnit test using the `UseMockClient` trait. It demonstrates configuring the mock client, including setting a default exception for uncalled requests. ```php client = $this->mockClient(function (Client $client): Client { $client->setDefaultException(new \Exception('Dont call me!')); return $client; }); } } ``` -------------------------------- ### Install phpro/http-tools via Composer Source: https://github.com/phpro/http-tools/blob/v2.x/README.md This command installs the phpro/http-tools package using Composer, the dependency manager for PHP. Ensure Composer is installed and accessible in your environment. ```bash composer require phpro/http-tools ``` -------------------------------- ### Example Usage of SDK Client (PHP) Source: https://github.com/phpro/http-tools/blob/v2.x/docs/sdk.md This snippet demonstrates how to instantiate and use the MyClient SDK. It shows initializing the client with a transport and then calling methods on the aggregated resources, such as finding a user by their identifier. ```php /** @var TransportInterface $transport */ /** @var MyClient $sdk */ $sdk = new MyClient($transport); var_dump($sdk->users->find('veewee')); ``` -------------------------------- ### Setting up HTTP Clients with Factories Source: https://github.com/phpro/http-tools/blob/v2.x/README.md Demonstrates how to create HTTP clients using different factory classes provided by phpro/http-tools. It shows how to pass middleware, configuration options, and mentions the auto-discovery and specific client factories (Guzzle, Symfony). Includes an example of wrapping additional HTTPlug plugins. ```php $_ENV['SOME_CLIENT_BASE_URI']]; $httpClient = AutoDiscoveredClientFactory::create($middlewares); $httpClient = GuzzleClientFactory::create($guzzlePlugins, $options); $httpClient = SymfonyClientFactory::create($middlewares, $options); // If you are using guzzle, you can both use guzzle and httplug plugins. // You can wrap additional httplug plugins like this: $httpClient = PluginsConfigurator::configure($httpClient, $middlewares); ``` -------------------------------- ### Install ReactPHP Async and PSR-18 Client Bridge Source: https://github.com/phpro/http-tools/blob/v2.x/README.md This command installs the necessary packages to enable asynchronous HTTP requests using ReactPHP's async capabilities and a PSR-18 client bridge for ReactPHP. ```sh composer require react/async veewee/psr18-react-browser ``` -------------------------------- ### Configuring Client Plugins and Middleware Source: https://github.com/phpro/http-tools/blob/v2.x/README.md Illustrates how to configure HTTP client plugins and middleware for extending functionality. It provides examples of using built-in plugins like `AcceptLanguagePlugin` and `CallbackPlugin`, and suggests using the vast array of available HTTPlug middleware. ```php * @psalm-readonly */ public $users; /** * @param TransportInterface $transport */ public function __construct(TransportInterface $transport) { $this->users = new UsersResource($transport); } } ``` -------------------------------- ### PHPUnit Trait for Creating HTTP Tools Request Source: https://github.com/phpro/http-tools/blob/v2.x/README.md An example demonstrating the use of the `UseHttpToolsFactories` trait in PHPUnit tests to create HTTP tools-specific request objects. This allows for easier testing of transports and middlewares. ```php $request = $this->createToolsRequest('GET', '/some-endpoint', [], ['hello' => 'world']); ``` -------------------------------- ### Define a Users Resource with CRUD Operations (PHP) Source: https://github.com/phpro/http-tools/blob/v2.x/docs/sdk.md This snippet defines a UsersResource class that extends HttpResource and utilizes traits for common REST operations like Create, Find, Get, Update, Patch, and Delete. It also includes a custom 'me' method to fetch the current user's data. ```php use Phpro\HttpTools\Sdk\HttpResource; use Phpro\HttpTools\Sdk\Rest; use Phpro\HttpTools\Request\Request; /** * @template ResultType * @extends HttpResource */ final class UsersResouce extends HttpResource { use Rest\CreateTrait; use Rest\FindTrait; use Rest\GetTrait; use Rest\UpdateTrait; use Rest\PatchTrait; use Rest\DeleteTrait; protected function path(): string { return '/users'; } public function me() { $request = new Request('GET', '/user', [], null); return $this->transport()($request); } } ``` -------------------------------- ### PHP Async Request Handler with TransportInterface Source: https://github.com/phpro/http-tools/blob/v2.x/README.md An example of an asynchronous request handler in PHP that utilizes the TransportInterface. It processes a FetchRequest and returns a Something object, demonstrating synchronous-like coding with asynchronous operations. ```php */ private TransportInterface $transport ) {} public function __invoke(FetchRequest $request): Something { return Something::tryParse( ($this->transport)($data) ); } } ``` -------------------------------- ### PHP SDK REST Traits for Resource Operations Source: https://context7.com/phpro/http-tools/llms.txt Provides reusable REST operation traits (Create, Find, Get, Update, Delete) for building generic SDK-style clients. These traits abstract common HTTP methods for resource manipulation. Dependencies include HttpResource, various SdkRest traits, and TransportInterface. ```php */ class UsersResource extends HttpResource { use CreateTrait; // POST /users use FindTrait; // GET /users/{id} use GetTrait; // GET /users use UpdateTrait; // PUT /users/{id} use DeleteTrait; // DELETE /users/{id} protected function path(): string { return '/users'; } } // Usage /** @var TransportInterface $transport */ $users = new UsersResource($transport); $allUsers = $users->get(['status' => 'active']); $user = $users->find('123'); $newUser = $users->create(['name' => 'Jane', 'email' => 'jane@example.com']); $updated = $users->update('123', ['name' => 'Jane Doe']); $users->delete('123'); ``` -------------------------------- ### Upload file using MultiPartEncoder and symfony/mime in PHP Source: https://github.com/phpro/http-tools/blob/v2.x/docs/files.md Illustrates uploading files using the MultiPartEncoder, which internally uses symfony/mime. This example shows how to configure the transport and send a POST request with form data including a file. ```php use Phpro\HttpTools\Encoding\Json\JsonDecoder; use Phpro\HttpTools\Encoding\Mime\MultiPartEncoder; use Phpro\HttpTools\Transport\EncodedTransportFactory; use Symfony\Component\Mime\Part\DataPart; use Symfony\Component\Mime\Part\Multipart\FormDataPart; use Phpro\HttpTools\Request\Request; $transport = EncodedTransportFactory::create( $client, $uriBuilder, MultiPartEncoder::createWithAutodiscoveredPsrFactories(), JsonDecoder::createWithAutodiscoveredPsrFactories() ); $jsonData = $transport( new Request('POST', '/some/file', [], new FormDataPart([ 'name' => 'Jos bos', 'profile-pic' => DataPart::fromPath('/my-profile-pic.jpg') ])) ); ``` -------------------------------- ### Upload file using StreamEncoder and guzzle/psr7 in PHP Source: https://github.com/phpro/http-tools/blob/v2.x/docs/files.md Shows an alternative method for uploading files using the StreamEncoder with guzzle/psr7's MultipartStream. This setup allows for sending multipart form data, compatible with the EncodedTransportFactory. ```php use GuzzleHttp\Psr7\MultipartStream; use Phpro\HttpTools\Encoding\Json\JsonDecoder; use Phpro\HttpTools\Encoding\Stream\StreamEncoder; use Phpro\HttpTools\Transport\EncodedTransportFactory; use Symfony\Component\Mime\Part\DataPart; use Symfony\Component\Mime\Part\Multipart\FormDataPart; use Phpro\HttpTools\Request\Request; $transport = EncodedTransportFactory::create( $client, $uriBuilder, StreamEncoder::createWithAutodiscoveredPsrFactories(), JsonDecoder::createWithAutodiscoveredPsrFactories() ); $multiPartStream = new MultipartStream($parts) $jsonData = $transport( new Request('POST', '/some/file', [], $multiPartStream) ); ``` -------------------------------- ### Create SymfonyClient with Plugins and Options (PHP) Source: https://context7.com/phpro/http-tools/llms.txt Initializes a Symfony HTTP client, ensuring HTTPlug compatibility and enabling plugin support. Dependencies include Phpro\HttpTools\Client\Factory\SymfonyClientFactory, Http\Client\Common\Plugin\BaseUriPlugin, and Nyholm\Psr7\Uri. ```php 60, 'max_redirects' => 5, ]; $httpClient = SymfonyClientFactory::create($middlewares, $options); ``` -------------------------------- ### PHP: Integration Test with VCR HTTP Client Source: https://context7.com/phpro/http-tools/llms.txt Shows how to use the UseVcrClient trait for recording and replaying HTTP interactions in integration tests. This is useful for testing against real API endpoints without incurring repeated network requests after the first run. Dependencies include PHPUnit and VCR plugins. ```php client = AutoDiscoveredClientFactory::create([ ...$this->useRecording(__DIR__ . '/fixtures/vcr', new PathNamingStrategy()), ]); } public function testFetchesUserFromGithub(): void { $transport = JsonPreset::create($this->client, new RawUriBuilder()); $handler = new FetchGithubUser($transport); // First run: makes real HTTP request and records it // Subsequent runs: replays from recorded fixture $user = $handler(new FetchUserRequest('octocat')); $this->assertEquals('octocat', $user->login); } } ``` -------------------------------- ### Create GuzzleClient with Middleware and Options (PHP) Source: https://context7.com/phpro/http-tools/llms.txt Constructs a Guzzle HTTP client, incorporating native Guzzle middleware and configurable options. This function utilizes Phpro\HttpTools\Client\Factory\GuzzleClientFactory and GuzzleHttp\Middleware. ```php withHeader('X-Custom-Header', 'value'); }), ]; $options = [ 'base_uri' => 'https://api.example.com', 'timeout' => 30, 'headers' => [ 'User-Agent' => 'MyApp/1.0', ], ]; $httpClient = GuzzleClientFactory::create($guzzleMiddlewares, $options); ``` -------------------------------- ### Create AutoDiscoveredClient with Plugins (PHP) Source: https://context7.com/phpro/http-tools/llms.txt Creates an HTTP client using PSR-18 auto-discovery and applies specified middleware plugins for extended functionality. Dependencies include Phpro\HttpTools\Client\Factory\AutoDiscoveredClientFactory, Phpro\HttpTools\Plugin\AcceptLanguagePlugin, Http\Client\Common\Plugin\AuthenticationPlugin, and Http\Message\Authentication\Bearer. ```php createResponse( 201, ['Content-Type' => 'application/json'], json_encode(['id' => 123, 'name' => 'John', 'email' => 'john@example.com']) ); $client = $this->mockClient(function ($client) use ($mockResponse) { $client->addResponse($mockResponse); return $client; }); $transport = JsonPreset::create($client, new TemplatedUriBuilder()); $handler = new CreateUser($transport); $result = $handler(new CreateUserRequest('John', 'john@example.com')); $this->assertEquals(123, $result->id); $this->assertEquals('John', $result->name); } } ``` -------------------------------- ### Download file using BinaryDecoder in PHP Source: https://github.com/phpro/http-tools/blob/v2.x/docs/files.md Demonstrates downloading a file using the BinaryDecoder and BinaryDownloadPreset. It shows how to retrieve file metadata like stream, size, hash, extension, mime type, and filename from response headers and stream. ```php use Phpro\HttpTools\Encoding\Binary\BinaryFile; use Phpro\HttpTools\Request\Request; use Phpro\HttpTools\Transport\Presets\BinaryDownloadPreset; $transport = BinaryDownloadPreset::create($client, $uriBuilder); $binaryFile = $transport( new Request('GET', '/some/file', [], null) ); assert($binaryFile instanceof BinaryFile); var_dump( $binaryFile->stream(), $binaryFile->fileSizeInBytes(), $binaryFile->hash(), $binaryFile->extension(), $binaryFile->mimeType(), $binaryFile->fileName() ); ``` -------------------------------- ### Magento2 di.xml Configuration for phpro/http-tools Source: https://github.com/phpro/http-tools/blob/v2.x/docs/framework/magento2.md This XML configuration demonstrates how to set up phpro/http-tools within Magento2's dependency injection system. It shows how to define plugins, configure the HTTP client factory with middleware and options, and set up custom Transport and Request Handler classes. ```xml nl-BE \Phpro\HttpTools\Client\Factory\SymfonyClientFactory Phpro\HttpTools\Plugin\AcceptLanguagePlugin http://api.openweathermap.org Phpro\HttpTools\Client\Factory\LazyClientLoader Mage\OpenWeather\Http\Transport ``` -------------------------------- ### PHP Accept-Language Header Plugin for Http Clients Source: https://context7.com/phpro/http-tools/llms.txt Adds an Accept-Language header to all outgoing requests, aiding in internationalization. This plugin can be easily integrated into HTTP clients using middleware patterns. Dependencies include AcceptLanguagePlugin and an HTTP client factory. ```php 'v1']); $request = new Request( 'GET', '/api/{version}/users{?status,limit}', ['status' => 'active', 'limit' => 10], null ); $uri = $uriBuilder($request); // Result: /api/v1/users?status=active&limit=10 ``` -------------------------------- ### Create JsonPreset Transport (PHP) Source: https://context7.com/phpro/http-tools/llms.txt Generates a pre-configured transport for JSON APIs, which automatically handles JSON encoding and decoding. This requires Phpro\HttpTools\Transport\Presets\JsonPreset, Phpro\HttpTools\Uri\TemplatedUriBuilder, and Phpro\HttpTools\Client\Factory\AutoDiscoveredClientFactory. ```php and return array // Use with request handlers for type-safe API calls ``` -------------------------------- ### Implement a List Request Handler Source: https://github.com/phpro/http-tools/blob/v2.x/README.md This code defines a request handler class for fetching a list of items. It utilizes a TransportInterface to interact with the API and wraps the raw response data into a ListResponse value object. It includes notes on error handling and validation. ```php */ private TransportInterface $transport ) {} public function __invoke(ListRequest $request): ListResponse { // You could validate the result first + throw exceptions based on invalid content // Tip : never trust APIs! // Try to gracefully fall back if possible and keep an eye on how the implementation needs to handle errors! return ListResponse::fromRawArray( ($this->transport)($request) ); } } ``` -------------------------------- ### Advanced Logging with Sensitive Data Stripping Source: https://github.com/phpro/http-tools/blob/v2.x/README.md Shows how to implement advanced logging for HTTP requests using the `php-http/logger-plugin`. It demonstrates the use of `RemoveSensitiveHeadersFormatter` and `RemoveSensitiveJsonKeysFormatter` to strip sensitive information from logs, allowing control over logging detail via a debug parameter. ```php async(fn () => $handler(new FetchRequest($id))); $things = await(parallel([ $run(1), $run(2), $run(3), ])); ``` -------------------------------- ### Define List Response Value Object Source: https://github.com/phpro/http-tools/blob/v2.x/README.md This code defines a ListResponse value object for sanitizing and normalizing API response data. The `fromRawArray` static method is used for creating instances from raw array data. The `getItems` method provides access to the item list, with fallback for missing keys. ```php data['items'] ?? []); } } ``` -------------------------------- ### Create Custom JSON Transport Preset Source: https://github.com/phpro/http-tools/blob/v2.x/README.md This snippet demonstrates how to create a custom transport preset for handling JSON payloads. It utilizes JsonPreset for JSON encoding/decoding and TemplatedUriBuilder for URI construction. The custom transport wrapper is designed to handle specific error properties. ```php async(fn () => $handler(new FetchUserRequest($id))); $users = await(parallel([ $run(1), $run(2), $run(3), ])); // All three requests executed concurrently foreach ($users as $user) { echo $user->name . "\n"; } ``` -------------------------------- ### Configure Symfony HTTP Client with Plugins and Options Source: https://github.com/phpro/http-tools/blob/v2.x/docs/framework/symfony.md This configuration sets up a Symfony HTTP client using the SymfonyClientFactory. It allows for injecting custom middlewares via tagged services and provides options like setting a base URI from environment variables. Other factory options like GuzzleClientFactory and AutoDiscoveredClientFactory are commented out but available. ```yaml services: # # Configuring an HTTP client: # App\SomeClient\HttpClient: factory: ['Phpro\HttpTools\Client\Factory\SymfonyClientFactory', 'create'] # factory: ['Phpro\HttpTools\Client\Factory\GuzzleClientFactory', 'create'] # factory: ['Phpro\HttpTools\Client\Factory\AutoDiscoveredClientFactory', 'create'] arguments: $middlewares: !tagged app.someclient.plugin $options: base_uri: '%env(SOME_CLIENT_BASE_URI)%' # # Configuring plugins: # App\SomeClient\Plugin\AcceptLanguagePlugin: class: Phpro\HttpTools\Plugin\AcceptLanguagePlugin arguments: - 'nl-BE' tags: - { name: 'app.someclient.plugin' } App\SomeClient\Plugin\Authentication\ServicePrincipal: arguments: - '%env(API_SECRET)%' tags: - { name: 'app.someclient.plugin' } # # Logging: # App\SomeClient\Plugin\Logger: class: 'Http\Client\Common\Plugin\LoggerPlugin' arguments: - '@monolog.logger.someclient' - '@app.http.logger_formatter' tags: - { name: 'app.someclient.plugin', priority: 1000 } app.http.logger_formatter: stack: - Phpro\HttpTools\Formatter\RemoveSensitiveHeadersFormatter: $formatter: '@.inner' $sensitiveHeaders: - 'X-Api-Key' - 'X-Api-Secret' - Phpro\HttpTools\Formatter\RemoveSensitiveJsonKeysFormatter: $formatter: '@.inner' $sensitiveJsonKeys: - password - oldPassword - refreshToken - '@app.http.logger_formatter.base' app.http.logger_formatter.base: factory: ['Phpro\HttpTools\Formatter\Factory\BasicFormatterFactory', 'create'] class: Http\Message\Formatter arguments: $debug: '%kernel.debug%' $maxBodyLength: 1000 # # Setting up the transport # App\SomeClient\Transport: class: Phpro\HttpTools\Transport\TransportInterface factory: ['Phpro\HttpTools\Transport\Presets\JsonPreset', 'sync'] arguments: - '@App\SomeClient' - '@Phpro\HttpTools\Uri\TemplatedUriBuilder' Phpro\HttpTools\Uri\TemplatedUriBuilder: ~ # # Registering a single Request Handler # App\SomeClient\RequestHandler\ListSomething: arguments: - '@App\SomeClient\Transport' # # Or register all Request Handlers at once # App\SomeClient\RequestHandler\: resource: '../../RequestHandler/*' bind: $transport: '@App\SomeClient\Transport' ``` -------------------------------- ### Creating an EncodedTransport - PHP Source: https://github.com/phpro/http-tools/blob/v2.x/docs/transports.md Demonstrates how to create a custom configured transport using the EncodedTransportFactory. This factory requires an HTTP client, a URI builder, an encoder, and a decoder to assemble the transport. ```php use Phpro\HttpTools\Transport\EncodedTransportFactory; EncodedTransportFactory::create( $client, $uriBuilder, $encoder, $decoder ); ``` -------------------------------- ### PHP: FormUrlencodedPreset for Form Data Requests Source: https://context7.com/phpro/http-tools/llms.txt Utilizes FormUrlencodedPreset to create transports for application/x-www-form-urlencoded requests. It simplifies sending form data and automatically sets the correct Content-Type header. The preset decodes responses as arrays. ```php 'client_credentials', 'client_id' => 'your-client-id', 'client_secret' => 'your-secret', ]); $response = $transport($request); // Returns decoded form data as array ``` -------------------------------- ### Create Weather HTTP Response Value Object in PHP Source: https://github.com/phpro/http-tools/blob/v2.x/docs/framework/magento2.md This PHP code defines a value object for handling weather data responses. It includes a constructor for type and description, and a static factory method `fromRawArray` to create an instance from raw array data, with basic validation. ```php type = trim($type); $this->description = trim($description); } public static function fromRawArray(array $data): self { if (!isset($data['weather']) || !is_array($data['weather']) || !isset($data['weather'][0]['main'])) { throw new \Exception('Invalid data provided'); } return new self( $data['weather'][0]['main'], $data['weather'][0]['description'] ); } public function getType(): string { return $this->type; } public function getDescription(): string { return $this->description; } } ``` -------------------------------- ### Define List Request Value Object Source: https://github.com/phpro/http-tools/blob/v2.x/README.md This code defines a ListRequest value object that implements the RequestInterface. It encapsulates request details such as HTTP method, URI, URI parameters, and body. Named constructors can be added to support different request variations, like filtering or POST data. ```php */ class ListRequest implements RequestInterface { public function method() : string { return 'GET'; } public function uri() : string { return '/list{?query}'; } public function uriParameters() : array { return [ 'query' => 'somequery', ]; } public function body() : array { return []; } } ``` -------------------------------- ### PHP Request Handler Pattern for API Interactions Source: https://context7.com/phpro/http-tools/llms.txt Implements a request handler that transforms request models to response models using a transport layer. It validates the API response structure and converts it into a typed UserResponse object. Dependencies include a TransportInterface and a CreateUserRequest object. ```php */ private TransportInterface $transport ) {} public function __invoke(CreateUserRequest $request): UserResponse { $responseData = ($this->transport)($request); if (!isset($responseData['id']) || !isset($responseData['name'])) { throw new \RuntimeException('Invalid API response structure'); } return UserResponse::fromArray($responseData); } } class UserResponse { private function __construct( public readonly int $id, public readonly string $name, public readonly string $email ) {} public static function fromArray(array $data): self { return new self( id: (int) ($data['id'] ?? 0), name: (string) ($data['name'] ?? ''), email: (string) ($data['email'] ?? '') ); } } // Usage $handler = new CreateUser($transport); $response = $handler(new CreateUserRequest('John Doe', 'john@example.com')); echo $response->id; // 123 ``` -------------------------------- ### PHP: EncodedTransportFactory for Custom Encoders/Decoders Source: https://context7.com/phpro/http-tools/llms.txt Explains the use of EncodedTransportFactory to create transports with custom JSON encoding and decoding capabilities. This factory allows for the injection of specific encoder and decoder implementations, offering flexibility beyond the standard presets. It's equivalent to JsonPreset but more configurable. ```php */ class CreateUserRequest implements RequestInterface { public function __construct( private string $name, private string $email ) {} public function method(): string { return 'POST'; } public function uri(): string { return '/api/users'; } public function uriParameters(): array { return []; } public function body(): array { return [ 'name' => $this->name, 'email' => $this->email, ]; } } ``` -------------------------------- ### PHP Transport Class for phpro/http-tools Source: https://github.com/phpro/http-tools/blob/v2.x/docs/framework/magento2.md This PHP class implements the `TransportInterface` for phpro/http-tools, acting as a decorator for HTTP requests. It utilizes `LazyClientLoader` and `TemplatedUriBuilder` to configure the underlying HTTP client and URI building, with `JsonPreset` providing JSON request/response handling. ```php jsonTransport = JsonPreset::create( $clientLoader->load(), $uriBuilder ); } public function __invoke(RequestInterface $request): array { return ($this->jsonTransport)($request); } } ``` -------------------------------- ### Configure SerializerTransport with SymfonySerializer Source: https://github.com/phpro/http-tools/blob/v2.x/docs/transports.md This snippet demonstrates how to instantiate and configure the SerializerTransport using SymfonySerializer. It requires the symfony/serializer component and a PSR-18 compliant HTTP client. The transport decodes responses into a specified output type. ```php use Phpro\HttpTools\Serializer\SymfonySerializer; use Phpro\HttpTools\Transport\Presets\RawPreset; use Phpro\HttpTools\Transport\Serializer\SerializerTransport; $transport = new SerializerTransport( new SymfonySerializer($theSymfonySerializer, 'json'), RawPreset::create($client, $uriBuilder) ); $transport->withOutputType(SomeResponse::class); ``` -------------------------------- ### Handle Weather HTTP Request with PHP Source: https://github.com/phpro/http-tools/blob/v2.x/docs/framework/magento2.md This PHP code defines a request handler for fetching weather data. It uses a TransportInterface to send a WeatherRequest and converts the raw response into a WeatherResponse object. Error handling and data conversion can be added within the handler. ```php transport = $transport; } public function __invoke(WeatherRequest $weatherRequest): WeatherResponse { # You could add data conversion, error handling, ... here. return WeatherResponse::fromRawArray( ($this->transport)($weatherRequest) ); } } ``` -------------------------------- ### Define Weather HTTP Request Value Object in PHP Source: https://github.com/phpro/http-tools/blob/v2.x/docs/framework/magento2.md This PHP code defines a value object for a weather data request. It implements the RequestInterface and specifies the HTTP method, URI, URI parameters, and request body. The URI and parameters are templated for dynamic use. ```php 'Antwerp,be', 'appid' => '...' ]; } public function body(): array { return []; } } ``` -------------------------------- ### PHP Decorator for Masking Sensitive Headers in Logs Source: https://context7.com/phpro/http-tools/llms.txt A decorator for logging formatters that masks sensitive header values in logs to prevent data leakage. It wraps a base formatter and specifies headers to redact. Dependencies include RemoveSensitiveHeadersFormatter, BasicFormatterFactory, LoggerPlugin, and LoggerInterface. ```php