Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork5.3k
Document FQCN named controllers#7771
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
| <!-- app/config/services.xml--> | ||
| <services> | ||
| <serviceid="app.hello_controller"class="AppBundle\Controller\HelloController" /> | ||
| <serviceid="AppBundle\Controller\HelloController"class="AppBundle\Controller\HelloController" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Correct me if I'm wrong, but isn't this possible too?
<serviceid="AppBundle\Controller\HelloController" />
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Yes it is, but only in 3.3. I think we should keep a notation that works on every supported version as it's not the main subject.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Your aim is at the master branch, hence I thought you were doing this for 3.3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Everything that used to work before 3.3 should probably target the respective lower branches in separate PRs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
| use AppBundle\Controller\HelloController; | ||
| $container->register('app.hello_controller', HelloController::class); | ||
| $container->register(HelloController::class, HelloController::class); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Isn't something like this possible?
$container->register(HelloController::class);
I believe this also had a shortcut somehow.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Then we would have an example only working on 3.3, is it ok?
| services: | ||
| app.hello_controller: | ||
| AppBundle\Controller\HelloController: | ||
| class:AppBundle\Controller\HelloController |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
class can be omitted here as well
e5285f3 to99ba301Compare| <!-- app/config/services.xml--> | ||
| <services> | ||
| <serviceid="app.hello_controller"class="AppBundle\Controller\HelloController" /> | ||
| <serviceid="AppBundle\Controller\HelloController"class="AppBundle\Controller\HelloController" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
I'm 👎 for changing service ids in 2.x docs, or we should do it absolutely everywhere.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
It adds value only for controllers as it allows to use normal notations so I don't see the need to update all service ids. Also imo if it becomes the standard with 3.3 we should also promote it for 2.x.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
What do you call "normal notations"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Ok got it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
With fqcn named services you can use all controller notations (e.g.AppBundle\Controller\HelloController::fooAction,App:Hello:foo, etc.). No need to define the service if you use@Route.
With other service ids you have to use the single colon notation:app.hello_controller:fooAction.
| defined above with the id ``AppBundle\Controller\HelloController``:: | ||
| $this->forward('app.hello_controller:indexAction', array('name' => $name)); | ||
| $this->forward('AppBundle:Hello:index', array('name' => $name)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Although I don't get why this is related to the fact that we use a FQCN as id.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Because this doesn't work with other service ids (fqcn named services are managed differentlyhttps://github.com/symfony/symfony/blob/master/src/Symfony/Component/HttpKernel/Controller/ContainerControllerResolver.php#L70).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Ok got it too :).
weaverryan commentedMay 2, 2017 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
I think this is indeed a good idea! Can we update this to use annotations for routing (and of course also show yaml like we do in other places)? Before the class names, using@route was kind of a pain because you needed the extra annotation, but that's not true now. Overall, I like this - good explanations of the different syntaxes! |
javiereguiluz commentedMay 3, 2017
GuilhemN commentedMay 3, 2017
@javiereguiluz it removes the |
javiereguiluz commentedMay 3, 2017
I see. Then it makes sense. Thanks! |
GuilhemN commentedMay 3, 2017
@weaverryan I added an example with |
xabbuh commentedMay 4, 2017
@GuilhemN Can you resolve the conflicts here? |
GuilhemN commentedMay 4, 2017 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Sure, it's done. I can't rebase before tomorrow around 6pm but you can push on my repo if you want to merge this before. |
GuilhemN commentedMay 5, 2017
rebased |
GuilhemN commentedMay 10, 2017
Should I close this ? |
robfrawley commentedMay 11, 2017
I think we should keep this in |
GuilhemN commentedMay 11, 2017
I don't think that's a problem, we often change our practices even in older branches. Anyway, I'm closing this, I think the gain is not so big in 2.x because you have to duplicate the |
Uh oh!
There was an error while loading.Please reload this page.
This is possible since 2.7 but with 3.3 coming and the ability to have FQCN named services I think this is a more and more convenient notation that should be encouraged.