Skip to content
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

[3.3][DI] Service ids now default to the classname #7329

Closed
wouterj opened this issue Jan 7, 2017 · 4 comments
Closed

[3.3][DI] Service ids now default to the classname #7329

wouterj opened this issue Jan 7, 2017 · 4 comments

Comments

@wouterj
Copy link
Member

wouterj commented Jan 7, 2017

Symfony 3.3 has a really nice feature that allows to use the service class as its ID.

Reference: symfony/symfony#21133

@wouterj wouterj added this to the 3.3 milestone Jan 7, 2017
@wouterj wouterj changed the title [3.3][DI] Service id's now default to the classname [3.3][DI] Service ids now default to the classname Jan 7, 2017
@mickaelandrieu
Copy link
Contributor

@wouterj there are 2 ways to resolve this issue:

  • if you want to push this practice, we need to update all samples in docs with the "new" way to declare services
  • if you don't want to push the practice, a simple note in Dependency Injection component is enough

By the way, as I want to learn a little bit more about "what happens in DI since weeks" I'd like to take this issue :)

@javiereguiluz
Copy link
Member

My vote would be for the second option.

@wouterj
Copy link
Member Author

wouterj commented Jan 11, 2017

I think the service IDs as class names make sense for one case only: Services that are merely used for it's tag (e.g. custom listener, etc.).

I think we should update all examples that say "Then tag this service with XXX" to use this new behaviour and add a small section about this in the service container subguides, keeping all other service examples just using the new service IDs.

weaverryan added a commit that referenced this issue May 5, 2017
This PR was merged into the master branch.

Discussion
----------

Updates to DI config for 3.3

Hi guys!

WIP changes the new DI changes in 3.3! Woohoo! Some notes for myself:

This relates to, oh, just these 10+ issues :). Assume they will all be closed by this one PR - before merge, if any of them aren't covered, I'll remove them.

TODOS later (some might already be done)
- update to use `debug:container --types` (symfony/symfony#22624)
- update all other documents for possible changes for autowiring and autoconfigure
- new page for existing Symfony users to explain the changes
- update autowire section to talk about using aliases
- document instanceof and also the ability to add configuration to the PSR4 loader
- some links in the controller go to the API docs of `Controller`. But this is wrong, the methods
now live in `ControllerTrait`... but the API docs for traits is basically broken: http://api.symfony.com/master/Symfony/Bundle/FrameworkBundle/Controller/ControllerTrait.html
- how should we pass a parameter to a controller?
- do Twig extensions still need to be public? If so, the example in `service_container` about autoconfigure is still not quite right

Definitely included in this PR
* #7544
* #7482
* #7339
* #7672

Not included in this PR (but related to DI changes)
* #7329
* #7782
* #7777
* #7706
* #7608
* #7538
* #7441
* #7255
* ~~#7041~~
* ~~#7445~~
* ~~#7444~~
* ~~#7436~~

Commits
-------

22adfbd removing duplicate target
12c4944 Tweaks after amazing review from @GuilhemN and @xabbuh
cac3c6c Merge remote-tracking branch 'origin/master' into di-3.3-changes
2229fd3 Merge remote-tracking branch 'origin/master' into di-3.3-changes
5452c61 Adding section about public: false
ee27765 Adding versionadded
bc7088d Merge remote-tracking branch 'origin/di-3.3-changes' into di-3.3-changes
443aec2 Merge pull request #7857 from GuilhemN/patch-1
89e12de bad link
6de83e2 fixing build problem
759e9b2 last tweaks from feedback
45500b3 Adding details and usages of fetching the service as a controller arg
70178d1 adding note about autoconfigure
6e6ed94 more tweaks
0e48bd8 [WIP] Updates to DI config for 3.3
9ab27f0 Add xml files
2636bea bad link
c45daf4 fixing build problem
9e84572 last tweaks from feedback
049df7d Adding details and usages of fetching the service as a controller arg
105801c adding note about autoconfigure
2d11347 more tweaks
8433fc1 [WIP] Updates to DI config for 3.3
@javiereguiluz
Copy link
Member

Closing as fixed because after the latest updates, we always use service injection via autowiring and type-hints and in some cases we show the ->get(Something::class) alternative, so we're always using FQCN ids. The only place where we show old IDs is in the docs explaining how to update from old Symfony to new Symfony and how can you alias services.

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

No branches or pull requests

3 participants