Do not register default HttpClient to prevent auto wire issues
ruudk opened this issue · 2 comments
| Q | A |
|---|---|
| Bug? | no |
| New Feature? | yes |
| Version | 1.14.0 |
Actual Behavior
We are heavily using Symfony's auto wire functionality. Sometimes, developer inject HttpClient in the constructor without actually specifying the exact httplug.client.name. No error is thrown, and HTTPlug just picks the httplug.client.default service (or the first client it can find)
Expected Behavior
Don't register a default Http\Client\HttpClient service and Symfony will automatically warn the developer that multiple services of Http\Client\HttpClient exist. Developer is then notified about this and will think :)
Possible Solutions
I really propose to get rid of this behaviour in the next major version of this bundle.
Related code
HttplugBundle/DependencyInjection/HttplugExtension.php
Lines 115 to 123 in 8b7cb00
HttplugBundle/Resources/config/services.xml
Lines 44 to 46 in a6466b4
hm, i think that really depends on the scenario, or use case of your application. if it is small and needs only one client, autowiring might be desired. if it is large, it is not desired.
the best solution probably is a configuration option that by default and in the recipe is off, but that you can enable to support autowiring. do you want to do a pull request for that? we can add it in the current system but with the default being enabled, and change the default in the next major version - as you say, that is a BC break.