casts the response content to a PHP stream resource $content = $response ->toStream()
casts the response JSON content to a PHP array $content = $response ->toArray() gets the response body as a string $content = $response ->getContent() gets the HTTP headers as string with the header names lower-cased $headers = $response ->getHeaders() Symfony\Contracts\HttpClient\HttpClientInterface $githubClientĪs the type and name of an argument, autowiring will inject the github.clientģ1 $response = $client ->request( 'GET', ' // gets the HTTP status code of the response $statusCode = $response ->getStatusCode() Methods defined by Symfony to choose a specific service.Įach client has a unique service named after its configuration.Įach scoped client also defines a corresponding named autowiring alias. If you use scoped clients in the Symfony framework, you must use any of the Requested URL matches one of the regular expressions set by the scope option. You can define several scopes, so that each set of options is added only if a
relative URLs will use the 2nd argument as base URI and use the options of the 3rd argument $client = ScopingHttpClient ::forBaseUri( $client, '', [ the options defined as values apply only to the URLs matching // the regular expressions defined as keys ' => [ $client = new ScopingHttpClient( $client, [ Use Symfony\ Component\ HttpClient\ ScopingHttpClient 30 application/3+json token %env(GITHUB_API_TOKEN)% application/3+json token %env(GITHUB_API_TOKEN)% Ģ3 use Symfony\ Component\ HttpClient\ HttpClient