Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Discussion options

In "Best Practices for Reusable Bundles", there is a recommandation regarding services:

Services should not use autowiring or autoconfiguration. Instead, all services should be defined explicitly.

But there are no explications about why we shound't use autowiring and/or autoconfiguration on services... Is it possible to have some explanation about why we shouldn't?

You must be logged in to vote

Using autoconfiguration means that you don't control the actual shape of your services, as any autoconfiguration rule added elsewhere (by other bundles or by projects themselves) could change how your own service gets wired (which tags it has for instance).
In practice, this makes it harder to preserve BC between versions (you cannot know whether your code change will trigger new autoconfiguration rules to match, or some rules to not match anymore, as you cannot know what those rules are in all projects using the bundle) and also to provide support (as reproducing the issue might involve first discovering what autoconfiguration did).

If you accept those risk as a maintainer of the package…

Replies: 1 comment · 1 reply

Comment options

Using autoconfiguration means that you don't control the actual shape of your services, as any autoconfiguration rule added elsewhere (by other bundles or by projects themselves) could change how your own service gets wired (which tags it has for instance).
In practice, this makes it harder to preserve BC between versions (you cannot know whether your code change will trigger new autoconfiguration rules to match, or some rules to not match anymore, as you cannot know what those rules are in all projects using the bundle) and also to provide support (as reproducing the issue might involve first discovering what autoconfiguration did).

If you accept those risk as a maintainer of the package, you can still use them.

You must be logged in to vote
1 reply
@caudurieau
Comment options

Thanks @stof. I suggest to add this explanation into the documentation as I doubt I'm the first to question this recommendation.

Answer selected by caudurieau
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
🙏
Q&A
Labels
None yet
2 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.