Symfony-docs: AnnotationException in "@Route and @Method" article example

Created on 29 Jul 2011  路  5Comments  路  Source: symfony/symfony-docs

In reference to article: http://symfony.com/doc/2.0/bundles/SensioFrameworkExtraBundle/annotations/routing.html

The last example that uses @Method annotation will throw the following exception:

AnnotationException: [Semantical Error] The annotation "@Method" in method Sensio\BlogBundle\Controller\PostController::showAction() was never imported.

This is happening because the following "use" is missing:

use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;

Most helpful comment

I must put:
use Sensio\BundleFrameworkExtraBundle\Configuration\Method;

All 5 comments

This is actually an issue with the SensioFrameworkExtraBundle, and I've just made a pull request to that repo to fix this: https://github.com/sensio/SensioFrameworkExtraBundle/pull/58

Thanks!

Awesome, thanks! I was wanting to make the change myself but was not able to locate the doc in this repo. Good to know that I should also look in the SensioFrameworkExtraBundle source.

ok so does this have anything to do with adding any comments starting with an @ on a given controller which is routed as using annotation routes? i.e. i have a comment @manual http://us2.php.net/manual/en/book.curl.php on one of my controllers and i get this error
[Semantical Error] The annotation "@manual" in method ApiBundle... was never imported. Did you maybe forget to add a "use" statement for this annotation?)

@wolfdogg you should add the @manual comment to the ignored list. Read more about that in http://docs.doctrine-project.org/projects/doctrine-common/en/latest/reference/annotations.html

Or, if you only use it once, you can use the @IgnoreAnnotation annotation to temporary ignore that annotation.

This only needs to be done for non-phpdoc standard annotations which are not included.

I must put:
use Sensio\BundleFrameworkExtraBundle\Configuration\Method;

Was this page helpful?
0 / 5 - 0 ratings