[GC] Why bundles shouldn't autowire/autoconfigure? #62031
-
In "Best Practices for Reusable Bundles", there is a recommandation regarding services:
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? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment · 1 reply
-
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). If you accept those risk as a maintainer of the package, you can still use them. |
Beta Was this translation helpful? Give feedback.
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…