symfony2 路由失败 - 无法重新声明类 [英] symfony2 routing failed - cannot redeclare class
问题描述
我正在尝试将我的路由从注释更改为 thr routing.yml.这是现在我routing_dev.yml 中唯一的配置:
i'm trying to change my routing from annotations to thr routing.yml. This is now the only configuration in my routing_dev.yml:
user.index:
pattern: /
defaults: { _controller: AcmeMyBundle:User/UserIndex:index }
这是错误:
Fatal error: Cannot redeclare class Acme\MyBundle\Controller\User\UserIndexController in C:\Users\gp\Desktop\xampp\htdocs\project\src\Acme\MyBundle\Controller\User\UserIndexController.php on line 56
为什么会这样?这确实是唯一具有此名称的类.我在 UserIndexController 中没有注释.
Why does it happen? This is really the only class with this name. I have no annotations in the UserIndexController.
有人有想法吗?非常感谢.
Has anybody an idea? Thank you very much.
推荐答案
尝试在您的项目中 grep/find Acme\MyBundle\Controller\User\UserIndexController
.
Try to grep/find in your project for Acme\MyBundle\Controller\User\UserIndexController
.
您可能真的将类声明了两次.
You maybe really have the class declared twice.
然后,尝试替换
`AcmeMyBundle:User/UserIndex:index`
与AcmeMyBundle:User\\UserIndex:index
根据 symfony 的版本,它会搜索namespace like"和/或path like".
Depending of the version of symfony, it will search for a "namespace like" and/or a "path like".
这篇关于symfony2 路由失败 - 无法重新声明类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!