Skip to content

Enable autowiring support for symfony 3.3+ #142

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 5, 2017

Conversation

stof
Copy link
Contributor

@stof stof commented Apr 5, 2017

Q A
Bug fix? no
New feature? yes
BC breaks? no
Deprecations? no
Related tickets n/a
Documentation n/a
License MIT

What's in this PR?

This configure the httplug.client as being the right choice for autowiring in Symfony 3.3+ when being asked to autowire a Http\Client\HttpClient typehint.
This also adds autowiring for all the message factory interfaces, using the main aliases as target.

Why?

Autowiring is one of the nice features of Symfony 3.3+ (working autowiring actually. We already have autowiring since 2.8 but it was not working well). So it is great to support it out of the box, especially when it has no impact for people using older versions or not using autowiring (the private alias just gets removed during the container optimizations anyway).

Autowiring support cannot be enabled for Symfony 2.8 to 3.1 for people using multiple clients because resolving ambiguities cannot be done by targeting an alias in these versions. Projects using a single client may experience a working autowiring in this case. But enabling the discovery in auto mode (which is the case by default) creates a second client, and using any decorator client (flexible_client, http_methods_client or batch_client features) also involves creating additional services implementing the interface, so it is quite unlikely to work fine for them (and there is nothing we can do about except migrating to Symfony 3.3 to have the improved autowiring as fixing this case is one of the main improvements).
We could do hacks to have this autowiring working in some cases, but the code would be quite ugly and would still have many cases where it would create WTF behaviors instead of the expected one. So I preferred not to support autowiring out of the box in Symfony < 3.3 instead.

@Nyholm Nyholm self-requested a review April 5, 2017 17:33
@stof
Copy link
Contributor Author

stof commented Apr 5, 2017

don't merge it yet. I forgot other aliases for the other main services

@stof
Copy link
Contributor Author

stof commented Apr 5, 2017

here we go

@Nyholm
Copy link
Member

Nyholm commented Apr 5, 2017

Great. I did not know. Thanks!

@Nyholm Nyholm merged commit 19a303a into php-http:master Apr 5, 2017
@dbu
Copy link
Collaborator

dbu commented Apr 6, 2017 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants