PHP Symfony2与旧包的错误映射
问题描述:
我正在学习Symfony2,并使用Doctrine2作为ORM。 除了一个错误,一切都很顺利。事实上,这个错误阻止了我,因为她发生在每一页和CLI上。PHP Symfony2与旧包的错误映射
误差如下:
ErrorException: Warning: class_parents(): Class BumpMe\UserBundle\Entity\User does not exist and could not be loaded in /home/gp2mv3/www/bumpme/vendor/doctrine/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php line 223
该用户实体是在UserBundle但我在另一个束(的appbundle)移动它(文件)。我重命名了文件和其中的命名空间。 之后,我删除UserBundle没有错误。
而现在,很多CLI命令后,我就把它......
我怎样才能解决这个问题呢? 这个错误来自哪里?
谢谢。
答
我发现了错误! 我在app/config/config.yml
中忘了一个声明。
如果你有同样的错误,重读每个文件,你可能会发现一个旧的未经编辑的声明。
# app/config/config.yml
fos_user:
db_driver: orm # other valid values are 'mongodb', 'couchdb' and 'propel'
firewall_name: main
# Allows you to enter the new user entity
user_class: MyApp\Bundle\UserBundle\Entity\User
# Used to enter the new registration form
registration:
form:
type: myapp_user_registrationform
答
我也有这个错误。
我有一个老/Resources/config/doctrine/User.orm.yml
文件从当我提出从我MainBundle我的用户到它自己的UserBundle(使用注解)
答
有点过时,但我遇到同样的错误潜伏,所以检查config.yml(我是根据“安装”)的编辑,在这里它,在最后一行:'Acme的用户负载,这也许帮助别人:
fos_user:
db_driver: orm # other valid values are 'mongodb', 'couchdb' and 'propel'
firewall_name: main
user_class: Acme\UserBundle\Entity\User
`BumpMe \ UserBundle`和`另一束(的appbundle) `?!粘贴User类的`namespace`字符串和它的确切完整路径 – meze 2011-12-17 01:22:56
`BumpMe \ AppBundle \ Entity \ User`我想,其实我刚刚复制了User.php文件,并且在这个文件中更改了命名空间。 – Gp2mv3 2011-12-17 11:23:00