Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

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

Closed
GuilhemN wants to merge3 commits intosymfony:2.7fromGuilhemN:CONTROLLERASASERVICE

Conversation

@GuilhemN
Copy link
Contributor

@GuilhemNGuilhemN commentedApr 8, 2017
edited
Loading

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.

<!-- app/config/services.xml-->
<services>
<serviceid="app.hello_controller"class="AppBundle\Controller\HelloController" />
<serviceid="AppBundle\Controller\HelloController"class="AppBundle\Controller\HelloController" />
Copy link
Contributor

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" />

Copy link
ContributorAuthor

@GuilhemNGuilhemNApr 8, 2017
edited
Loading

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.

Copy link
Contributor

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

Copy link
Member

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.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

@xabbuh you're right, I rebased this PR on 2.7.

@iltar I'll propose using the short notation in a new PR for 3.3, I should have done that since the beginning. Thanks for your comments!

use AppBundle\Controller\HelloController;
$container->register('app.hello_controller', HelloController::class);
$container->register(HelloController::class, HelloController::class);
Copy link
Contributor

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.

Copy link
ContributorAuthor

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
Copy link
Contributor

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

<!-- app/config/services.xml-->
<services>
<serviceid="app.hello_controller"class="AppBundle\Controller\HelloController" />
<serviceid="AppBundle\Controller\HelloController"class="AppBundle\Controller\HelloController" />
Copy link
Contributor

@HeahDudeHeahDudeApr 12, 2017
edited
Loading

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.

Copy link
ContributorAuthor

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.

HeahDude reacted with thumbs down emoji
Copy link
Contributor

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"?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Ok got it.

Copy link
ContributorAuthor

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));
Copy link
Contributor

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.

Copy link
ContributorAuthor

@GuilhemNGuilhemNApr 12, 2017
edited
Loading

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).

Copy link
Contributor

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
Copy link
Member

weaverryan commentedMay 2, 2017
edited
Loading

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
Copy link
Member

@GuilhemN thanks for this contribution. Just asking: why#7864 proposes the same changes for the master branch? Isn't a duplicate of this one?

@GuilhemN
Copy link
ContributorAuthor

@javiereguiluz it removes theclass attributes which are useless on master (see588333a)

@javiereguiluz
Copy link
Member

I see. Then it makes sense. Thanks!

@GuilhemN
Copy link
ContributorAuthor

@weaverryan I added an example with@Route, is this what you meant?

@xabbuh
Copy link
Member

@GuilhemN Can you resolve the conflicts here?

xabbuh added a commit that referenced this pull requestMay 4, 2017
…eguiluz)This PR was merged into the master branch.Discussion----------[3.3] Document FQCN named controllersAdaptation of#7771 for the master branch.Commits-------5fb2003 Minor reword588333a [3.3] Document FQCN named controllers49f589c Document FQCN named controllers
@GuilhemN
Copy link
ContributorAuthor

GuilhemN commentedMay 4, 2017
edited
Loading

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.

@GuilhemNGuilhemNforce-pushed theCONTROLLERASASERVICE branch from7b53ef2 to280a5c7CompareMay 5, 2017 15:40
@GuilhemN
Copy link
ContributorAuthor

rebased

@GuilhemN
Copy link
ContributorAuthor

Should I close this ?
We can apply the change of#7864 to older branches to accomodate people faster to the use of fqcn controllers but that's not mandatory. Having this only in 3.3 is good enough for me so that's up to you :)

@robfrawley
Copy link
Contributor

I think we should keep this in3.3 only. We shouldn't go changing the older docs out from under people. It will make them not align with other tutorials and external documentation for the2.x branch, IMHO.

@GuilhemN
Copy link
ContributorAuthor

It will make them not align with other tutorials and external documentation for the 2.x branch, IMHO.

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 theclass attribute.

@GuilhemNGuilhemN deleted the CONTROLLERASASERVICE branchMay 11, 2017 16:02
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@xabbuhxabbuhxabbuh left review comments

@javiereguiluzjaviereguiluzjaviereguiluz approved these changes

+2 more reviewers

@linaorilinaorilinaori left review comments

@HeahDudeHeahDudeHeahDude left review comments

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

8 participants

@GuilhemN@weaverryan@javiereguiluz@xabbuh@robfrawley@linaori@HeahDude@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp