Symfony

HTTP Client

HttpClient service, requests, responses, scoped clients, authentication, retry strategies

18 perguntas de entrevistaยท
Mid-Level
1

Which Symfony component allows making HTTP requests to external services?

Resposta

Symfony's HttpClient component provides a modern and performant interface for making HTTP requests. It supports HTTP/2, asynchronous requests, streaming and integrates seamlessly with Symfony's service system via autowiring.

2

Which interface should be injected to use the HTTP client in a Symfony service?

Resposta

The HttpClientInterface is the standard contract for injecting the HTTP client via autowiring. This approach decouples code from the concrete implementation and facilitates testing by allowing easy mocking of the client.

3

Which HttpClient method performs an HTTP request and returns a ResponseInterface object?

Resposta

The request() method is the main HttpClient method. It accepts the HTTP method, URL and an options array. It returns a ResponseInterface object representing the response lazily, meaning the request is only executed when accessing the content.

4

How to retrieve the JSON content of an HTTP response as a PHP array?

5

Which option allows sending a JSON body in a POST request with HttpClient?

+15 perguntas de entrevista

Domine Symfony para sua proxima entrevista

Acesse todas as perguntas, flashcards, testes tecnicos, exercicios de code review e simuladores de entrevista.

Comece gratis