【发布时间】:2026-01-22 19:15:01
【问题描述】:
我有一个控制器,它对路由、方法、模板和 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().
如果我清除了我的缓存,那么它会再次起作用,但只有在我进行另一次更改之前,它才会再次发生。 在读取配置的注释信息时似乎遇到了问题,但我不明白为什么它在实际上没有对任何注释进行更改时起作用/不起作用。
【问题讨论】:
-
你能告诉我们你的控制器文件吗?
-
你使用的是什么版本的 Symfony?您在使用 eAccelerator 吗?
-
在将项目升级到 Symfony 2.2 后,我遇到了同样的问题。它似乎只发生在 prod 环境中,dev 没问题。它在清除缓存后工作,直到我在任何操作上使用 ParamConverter 击中另一个控制器,不一定是我正在击中的操作。之后,任何具有 ParamConverter 的控制器中的任何操作都不起作用。
-
不使用eAccelerator,最新稳定版2.2.0。谢谢 tetranz,很高兴知道这不仅仅是我。
标签: php symfony annotations