Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature #30419 [FrameworkBundle] Add integration of http-client compo…
…nent (Ioni14, nicoweb) This PR was merged into the 4.3-dev branch. Discussion ---------- [FrameworkBundle] Add integration of http-client component | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | - This PR adds the integration of the HttpClient component on FrameworkBundle. By default, two services are provided, one implementing SFC-HttpClient, and another PSR18: * `http_client` + its autowiring alias for `Symfony\Contracts\HttpClient\HttpClientInterface`) This service is automatically set to the best HTTP client available with the configuration given under the `framework.http_client` key. * `psr18.http_client` + its autowiring alias for `Psr\Http\Client\ClientInterface`). To make it work, one needs to provide autowiring aliases for `ResponseFactoryInterface` and `StreamFactoryInterface`, which are provided by [the recipe](https://github.com/symfony/recipes-contrib/blob/master/nyholm/psr7/1.0/config/packages/nyholm_psr7.yaml) for `nyholm/psr7` (but could be overriden by apps when using something else). * one can also configure the default options, and "scoped" clients. For example: ```yaml http_client: default_options: capath: '...' clients: github_client: default_options: base_uri: 'https://api.github.com' ``` This definition create a `github_client` service implementing SFC-HttpClient and a `psr18.github_client` one implementing PSR18, +2 corresponding named autowiring aliases: `HttpClientInterface $githubClient`, and `ClientInterface $githubClient`. Commits ------- f2d2cf3 work with attributes for xml config 0023a71 [FrameworkBundle] Add integration of http-client component
- Loading branch information
Showing
19 changed files
with
541 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
src/Symfony/Bundle/FrameworkBundle/Resources/config/http_client.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?xml version="1.0" ?> | ||
|
||
<container xmlns="http://symfony.com/schema/dic/services" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"> | ||
|
||
<services> | ||
<service id="http_client" class="Symfony\Contracts\HttpClient\HttpClientInterface"> | ||
<factory class="Symfony\Component\HttpClient\HttpClient" method="create" /> | ||
<argument type="collection" /> <!-- default options --> | ||
<argument /> <!-- max host connections --> | ||
</service> | ||
<service id="Symfony\Contracts\HttpClient\HttpClientInterface" alias="http_client" /> | ||
|
||
<service id="psr18.http_client" class="Symfony\Component\HttpClient\Psr18Client" autowire="true"> | ||
<argument type="service" id="http_client" /> | ||
</service> | ||
<service id="Psr\Http\Client\ClientInterface" alias="psr18.http_client" /> | ||
</services> | ||
</container> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.