Skip to content

Commit 43b5d4a

Browse files
wizacedricjaviereguiluz
authored andcommitted
Clarifying how to autowire scoped HTTP clients
The documentation didn't make it very clear that the key of the "scoped_clients" array was the actual service name that could be used to autowire the service. By using the same name in the code example and in the paragraph about autowiring, that should be clearer to the reader.
1 parent cff3403 commit 43b5d4a

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

http_client.rst

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ autoconfigure the HTTP client based on the requested URL:
215215
http_client:
216216
scoped_clients:
217217
# only requests matching scope will use these options
218-
github:
218+
github.client:
219219
scope: 'https://api\.github\.com'
220220
headers:
221221
Accept: 'application/vnd.github.v3+json'
@@ -224,7 +224,7 @@ autoconfigure the HTTP client based on the requested URL:
224224
225225
# using base_uri, relative URLs (e.g. request("GET", "/repos/symfony/symfony-docs"))
226226
# will default to these options
227-
github:
227+
github.client:
228228
base_uri: 'https://api.github.com'
229229
headers:
230230
Accept: 'application/vnd.github.v3+json'
@@ -245,7 +245,7 @@ autoconfigure the HTTP client based on the requested URL:
245245
<framework:config>
246246
<framework:http-client>
247247
<!-- only requests matching scope will use these options -->
248-
<framework:scoped-client name="github"
248+
<framework:scoped-client name="github.client"
249249
scope="https://api\.github\.com"
250250
>
251251
<framework:header name="Accept">application/vnd.github.v3+json</framework:header>
@@ -254,7 +254,7 @@ autoconfigure the HTTP client based on the requested URL:
254254
255255
<!-- using base-uri, relative URLs (e.g. request("GET", "/repos/symfony/symfony-docs"))
256256
will default to these options -->
257-
<framework:scoped-client name="github"
257+
<framework:scoped-client name="github.client"
258258
base-uri="https://api.github.com"
259259
>
260260
<framework:header name="Accept">application/vnd.github.v3+json</framework:header>
@@ -271,7 +271,7 @@ autoconfigure the HTTP client based on the requested URL:
271271
'http_client' => [
272272
'scoped_clients' => [
273273
// only requests matching scope will use these options
274-
'github' => [
274+
'github.client' => [
275275
'scope' => 'https://api\.github\.com',
276276
'headers' => [
277277
'Accept' => 'application/vnd.github.v3+json',
@@ -282,7 +282,7 @@ autoconfigure the HTTP client based on the requested URL:
282282
283283
// using base_url, relative URLs (e.g. request("GET", "/repos/symfony/symfony-docs"))
284284
// will default to these options
285-
'github' => [
285+
'github.client' => [
286286
'base_uri' => 'https://api.github.com',
287287
'headers' => [
288288
'Accept' => 'application/vnd.github.v3+json',
@@ -329,8 +329,8 @@ Each client has a unique service named after its configuration.
329329

330330
Each scoped client also defines a corresponding named autowiring alias.
331331
If you use for example
332-
``Symfony\Contracts\HttpClient\HttpClientInterface $myApiClient``
333-
as the type and name of an argument, autowiring will inject the ``my_api.client``
332+
``Symfony\Contracts\HttpClient\HttpClientInterface $githubClient``
333+
as the type and name of an argument, autowiring will inject the ``github.client``
334334
service into your autowired classes.
335335

336336
.. note::

0 commit comments

Comments
 (0)