Symfony2 ParamConverter与@Annotation无关(任何文件更改后必须清除缓存)

时间:2013-03-06 12:17:59

标签: php symfony annotations

我有一个使用Annotations for Route,Method,Template和ParamConverter的控制器 如果我在下一页上对文件进行任何更改(甚至是空白更改或注释),则会发生以下错误

Cannot import resource "/home/sites/MySite/src/Acme/Bundle/MyBundle/Controller/" from "/home/sites/MySite/app/config/routing.yml".

FileLoaderLoadException: Cannot import resource "/home/sites/MySite/src/Acme/Bundle/MyBundle/Controller/" from "/home/sites/MySite/app/config/routing.yml"

AnnotationException: [Semantical Error] The class "Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter" is not annotated with @Annotation. Are you sure this class can be used as annotation? If so, then you need to add @Annotation to the _class_ doc comment of "Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter". If it is indeed no annotation, then you need to add @IgnoreAnnotation("ParamConverter") to the _class_ doc comment of method Acme\Bundle\MyBundle\Controller\DefaultController::viewAction().

如果我清除缓存,那么它将再次起作用,但只有在我做出另一个更改之后,它才会再次发生。 在读取配置的注释信息时,它似乎遇到了问题,但是我无法理解为什么当实际上没有对任何注释进行更改时它的工作原理/不起作用。

1 个答案:

答案 0 :(得分:8)

啊,这是一个已知错误,已在FrameworkExtraBundle中修复。

https://github.com/symfony/symfony/issues/7283

现在要获取最新版本,只需将该库的需求更改为dev-master

即可
"require": {
    ...
    "symfony/symfony": "2.2.*",
    "sensio/framework-extra-bundle": "dev-master",
   ...
},

并运行composer update