Skip to content

Instantly share code, notes, and snippets.

@erop
Created March 23, 2020 11:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save erop/44dc45aee6f7c7c47b9d50bc7e5bf714 to your computer and use it in GitHub Desktop.
Save erop/44dc45aee6f7c7c47b9d50bc7e5bf714 to your computer and use it in GitHub Desktop.
Try to setup scoped HttpClient in services.xml
<?xml version="1.0" encoding="UTF-8" ?>
<container xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:framework="http://symfony.com/schema/dic/symfony"
xmlns="http://symfony.com/schema/dic/services"
xsi:schemaLocation="http://symfony.com/schema/dic/services
http://symfony.com/schema/dic/services/services-1.0.xsd
http://symfony.com/schema/dic/symfony
https://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
<services>
<service id="service_id"
class="service_class_FQCN"
autowire="true">
<argument id="Symfony\Contracts\HttpClient\HttpClientInterface"
type="service"
key="$scopedHttpClient"/>
</service>
<service id="service_class_FQCN"
alias="service_id"/>
</services>
<framework:config>
<framework:http-client>
<framework:scoped-client
name="scoped_http_client"
base-uri="%env(string:BASE_URI)%"
cafile="%env(string:CAFILE)%"
capath="%env(string:CA_PATH)%"
local-cert="%env(string:CERT_PATH)%"
local-pk="%env(string:KEY_PATH)%">
</framework:scoped-client>
</framework:http-client>
</framework:config>
</container>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment