Symfony-docs: Routing page suggest installing SensioFrameworkExtraBundle while Doctrine Annotations suffices

Created on 2 Oct 2018  路  5Comments  路  Source: symfony/symfony-docs

The first instruction on the Routing page (routing.rst) is to install the annotations Composer package, which turns out to be an alias for sensio/framework-extra-bundle.

However, in several places (see also https://github.com/sensiolabs/SensioFrameworkExtraBundle/pull/562/ and https://github.com/sensiolabs/SensioFrameworkExtraBundle/pull/585) it is mentioned that routing via annotations is part of Symfony core since version 3.4, and that the SensioFrameworkExtraBundle is not needed anymore.

However, when I don't require the Composer package/alias, I get the following error:

Cannot load resource "../../src/Controller/". Make sure annotations are installed and enabled.

After trying several things and almost giving up, I discovered that installing the doctrine/annotations Composer package did the trick.

I think it's better to change the documentation of the routing page such that doctrine/annotations is mentioned instead of annotations.

Most helpful comment

For me it was harder to understand than easier.

Nowhere on the page it is stated that annotations is a Symfony Flex alias, so I didn't know I was dealing with one. Before I discovered this, I was asking myself the following questions:

  • Why on earth would Composer want to install sensio/framework-extra-bundle while I only told it to install annotations?
  • Why does Composer install all these Doctrine packages like doctrine/persistence while I'm building a headless application without any local database?
  • Why does composer why sensio/framework-extra-bundle states that my project itself needs it, while I didn't give the command to install it?
  • Why does composer why annotations give an InvalidArgumentException with the message Could not find package "annotations" in your project"?

All 5 comments

You are right about this. However, the framework-extra-bundle package provides lots of other annotations besides @Route. Some of them are used in other parts of the code, so I think it's better to keep installing support for all these annotations instead of only installing support for @Route.

There's an open issue (https://github.com/symfony/symfony/issues/25361) to move ALL annotations into Symfony core. If we do that, then we'll update the docs as you say, because there will be no need install this bundle.

That's why I'm closing this issue for now as "won't fix" ... but we appreciate that you created it and we thank you for helping us improve the docs. Thanks!

OK, but to avoid confusion, isn't it better to replace the annotations alias by the real package name sensio/framework-extra-bundle?

That would have saved me time and would not have caused confusion.

I see that this is already proposed in #9742, but that PR doesn't seem to be merged?

We did it like this because "composer require annotations" is something easy to understand ... but "composer require sensio/framework-extra-bundle" is not that easy ("sensio": who or what is that?, "extra bundle": extra what? where are my annotations? etc.)

For me it was harder to understand than easier.

Nowhere on the page it is stated that annotations is a Symfony Flex alias, so I didn't know I was dealing with one. Before I discovered this, I was asking myself the following questions:

  • Why on earth would Composer want to install sensio/framework-extra-bundle while I only told it to install annotations?
  • Why does Composer install all these Doctrine packages like doctrine/persistence while I'm building a headless application without any local database?
  • Why does composer why sensio/framework-extra-bundle states that my project itself needs it, while I didn't give the command to install it?
  • Why does composer why annotations give an InvalidArgumentException with the message Could not find package "annotations" in your project"?

@javiereguiluz as RFC on the subjet will probably take some time can I open a PR to address this issue?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

x8core picture x8core  路  4Comments

fabpot picture fabpot  路  3Comments

samjarrett picture samjarrett  路  4Comments

javiereguiluz picture javiereguiluz  路  3Comments

wiser picture wiser  路  3Comments