当我安装时FOS用户包 (官方文档 https://github.com/FriendsOfSymfony/FOSUserBundle/blob/master/Resources/doc/index.md),我尝试生成我的表fos_user
使用这个命令:
php app/console doctrine:schema:update --force
但控制台返回以下消息
无需更新 - 您的数据库已与当前实体元数据同步
我使用 Symfony 2.1 和 FOSUserBundle 的最新版本。
应用程序/AppKernel.php包含
new FOS\UserBundle\FOSUserBundle(),
应用程序/配置/config.yml包含
fos_user:
db_driver: orm # other valid values are 'mongodb', 'couchdb' and 'propel'
firewall_name: main
user_class: Krpano\UserBundle\Entity\User
src/Krpano/UserBundle/Entity/User.php包含
namespace Krpano\UserBundle\Entity;
use FOS\UserBundle\Entity\User as BaseUser;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity
* @ORM\Table(name="pouet")
*/
class User extends BaseUser
{
/**
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
public function __construct()
{
parent::__construct();
// your own logic
}
}
当我尝试访问我的网站时出现此错误:
MappingException:在链配置的命名空间 FOS\UserBundle\Entity、Krpano\ServicesBundle\Entity 中找不到类“Krpano\UserBundle\Entity\User”
你能帮助我吗?
无需更新 - 您的数据库已与当前实体元数据同步
意味着您的实体由于 AppKernel.php 中缺少声明而未注册。
Doctrine 仅搜索活跃的捆绑包。
添加行后:
new Krpano\UserBundle\KrpanoUserBundle(),
像那样:
public function registerBundles()
{
$bundles = array(
...
new Krpano\UserBundle\KrpanoUserBundle(),
new FOS\UserBundle\FOSUserBundle(),
...
); ...
尝试这个:
php app/console doctrine:schema:update --force
如果教义回归:
Database schema updated successfully! "1" queries were executed
你的问题已解决。
我的回答只是卡洛斯·格拉纳多斯回答的补充。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)