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

DI: Explain the controller.service_arguments changes #7988

Closed
xabbuh opened this issue Jun 3, 2017 · 11 comments
Closed

DI: Explain the controller.service_arguments changes #7988

xabbuh opened this issue Jun 3, 2017 · 11 comments

Comments

@xabbuh
Copy link
Member

xabbuh commented Jun 3, 2017

The 3.3 version of the docs assume that the reader uses a Standard Edition based on the config we provide for Symfony 3.3 or uses Symfony Flex where you get the same config. However, someone having an existing application that was just upgraded to Symfony 3.3 does not have all controllers registered as services. We should think about how we could improve understanding for them to avoid confusions like in symfony/symfony#23033.

@AdrienSchz
Copy link

AdrienSchz commented Jul 4, 2017

Hi,

I have the same issue, and it doesn't fix it when i register my controller as a service.
The answer given by @chalasr doesn't work for me. When i put it as he wrote it, i have an issue saying that a tags entry must be an array.
And another one because no class is set for AppBundle\Controller\RegistrationController
I have this in my service.yml:

services:
    AppBundle\Controller\RegistrationController:
        class: AppBundle\Controller\RegistrationController
        autowire: true # or define your controller constructor and configure its arguments explicitly
        tags:
            - name: controller.service_arguments

@chalasr
Copy link
Member

chalasr commented Jul 4, 2017

You did not put it as I wrote it :)

- tags:
- - name: controller.service_arguments 
+ tags: ['controller.service_arguments']

@AdrienSchz
Copy link

Yeah I know but it didn't work when il write it this way. I got an error saying that a "tags" entry should be an array

@xabbuh
Copy link
Member Author

xabbuh commented Jul 4, 2017

@Stormkirk Please open an issue at https://github.com/symfony/symfony if you are using Symfony 3.3 and this doesn't work for you with some steps on how to reproduce your issue.

@AdrienSchz
Copy link

I'm not usine symfony 3.3 but 3.2.4

@xabbuh
Copy link
Member Author

xabbuh commented Jul 4, 2017

Well, the short notation for tags is a new feature of Symfony 3.3. And the controller.service_arguments tag also is not supported on Symfony 3.2. Please be sure to read the version of the documentation that matches the version of the Symfony version you use. :)

@max4ever
Copy link

max4ever commented Oct 4, 2017

@xabbuh https://symfony.com/doc/current/service_container.html . So i'm using symfony 3.3.9 with documentation 3.3 and if one follows the documentation example doesn't work. The "controller.service_arguments" is under the second-last paragraph "Importing Many Services at once with resource" 👎

@xabbuh
Copy link
Member Author

xabbuh commented Oct 4, 2017

@max4ever Can you show an example project with the changes that you did and that were not working for you?

@TomasVotruba
Copy link

I'm writing post about this feature but could not find it.

Found something in commit: cbedd79, but not in the docs (probably moved/deleted in master now)

And something like this is too vague: https://symfony.com/doc/current/service_container/3.3-di-changes.html#controllers-are-registered-as-services

@fabpot
Copy link
Member

fabpot commented Mar 31, 2019

symfony/symfony#30569 helps

symfony-splitter pushed a commit to symfony/framework-bundle that referenced this issue Mar 31, 2019
…message when a controller fails because it's not registered as a service (moynzzz)

This PR was squashed before being merged into the 4.3-dev branch (closes #30569).

Discussion
----------

[FrameworkBundle][HttpKernel] Provide intuitive error message when a controller fails because it's not registered as a service

| Q             | A
| ------------- | ---
| Branch?       | master <!-- see below -->
| Bug fix?      | no
| New feature?  | yes <!-- don't forget to update src/**/CHANGELOG.md files -->
| BC breaks?    | no     <!-- see https://symfony.com/bc -->
| Deprecations? | no <!-- don't forget to update UPGRADE-*.md and src/**/CHANGELOG.md files -->
| Tests pass?   | yes    <!-- please add some, will be required by reviewers -->
| Fixed tickets | #27787, symfony/symfony-docs#7988 <!-- #-prefixed issue number(s), if any -->
| License       | MIT
| Doc PR        | none <!-- required for new features -->

<!--
Write a short README entry for your feature/bugfix here (replace this comment block.)
This will help people understand your PR and can be used as a start of the Doc PR.
Additionally:
 - Bug fixes must be submitted against the lowest branch where they apply
   (lowest branches are regularly merged to upper ones so they get the fixes too).
 - Features and deprecations must be submitted against the master branch.
-->

Create a very late controller argument value resolver to throw an intuitive error message when controller fails because it is not registered as a service.

Commits
-------

fbfc623b72 [FrameworkBundle][HttpKernel] Provide intuitive error message when a controller fails because it's not registered as a service
symfony-splitter pushed a commit to symfony/http-kernel that referenced this issue Mar 31, 2019
…message when a controller fails because it's not registered as a service (moynzzz)

This PR was squashed before being merged into the 4.3-dev branch (closes #30569).

Discussion
----------

[FrameworkBundle][HttpKernel] Provide intuitive error message when a controller fails because it's not registered as a service

| Q             | A
| ------------- | ---
| Branch?       | master <!-- see below -->
| Bug fix?      | no
| New feature?  | yes <!-- don't forget to update src/**/CHANGELOG.md files -->
| BC breaks?    | no     <!-- see https://symfony.com/bc -->
| Deprecations? | no <!-- don't forget to update UPGRADE-*.md and src/**/CHANGELOG.md files -->
| Tests pass?   | yes    <!-- please add some, will be required by reviewers -->
| Fixed tickets | #27787, symfony/symfony-docs#7988 <!-- #-prefixed issue number(s), if any -->
| License       | MIT
| Doc PR        | none <!-- required for new features -->

<!--
Write a short README entry for your feature/bugfix here (replace this comment block.)
This will help people understand your PR and can be used as a start of the Doc PR.
Additionally:
 - Bug fixes must be submitted against the lowest branch where they apply
   (lowest branches are regularly merged to upper ones so they get the fixes too).
 - Features and deprecations must be submitted against the master branch.
-->

Create a very late controller argument value resolver to throw an intuitive error message when controller fails because it is not registered as a service.

Commits
-------

fbfc623 [FrameworkBundle][HttpKernel] Provide intuitive error message when a controller fails because it's not registered as a service
fabpot added a commit to symfony/symfony that referenced this issue Mar 31, 2019
…message when a controller fails because it's not registered as a service (moynzzz)

This PR was squashed before being merged into the 4.3-dev branch (closes #30569).

Discussion
----------

[FrameworkBundle][HttpKernel] Provide intuitive error message when a controller fails because it's not registered as a service

| Q             | A
| ------------- | ---
| Branch?       | master <!-- see below -->
| Bug fix?      | no
| New feature?  | yes <!-- don't forget to update src/**/CHANGELOG.md files -->
| BC breaks?    | no     <!-- see https://symfony.com/bc -->
| Deprecations? | no <!-- don't forget to update UPGRADE-*.md and src/**/CHANGELOG.md files -->
| Tests pass?   | yes    <!-- please add some, will be required by reviewers -->
| Fixed tickets | #27787, symfony/symfony-docs#7988 <!-- #-prefixed issue number(s), if any -->
| License       | MIT
| Doc PR        | none <!-- required for new features -->

<!--
Write a short README entry for your feature/bugfix here (replace this comment block.)
This will help people understand your PR and can be used as a start of the Doc PR.
Additionally:
 - Bug fixes must be submitted against the lowest branch where they apply
   (lowest branches are regularly merged to upper ones so they get the fixes too).
 - Features and deprecations must be submitted against the master branch.
-->

Create a very late controller argument value resolver to throw an intuitive error message when controller fails because it is not registered as a service.

Commits
-------

fbfc623 [FrameworkBundle][HttpKernel] Provide intuitive error message when a controller fails because it's not registered as a service
@wouterj wouterj modified the milestones: 3.3, 3.4 Apr 14, 2019
@javiereguiluz
Copy link
Member

I'm closing this issue because I think the current docs are enough ... and the improved error messages in Symfony perfectly explain what is happening and how to solve it. Thanks.

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

8 participants