不可能生成表“用户"表. [英] Impossible to generate the table "user"

查看:84
本文介绍了不可能生成表“用户"表.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我安装 FOSUserBundle (官方文档),我尝试使用以下命令生成表fos_user:

When I install FOSUserBundle (official documentation), I try to generate my table fos_user using this command:

php app/console doctrine:schema:update --force

但是控制台返回以下消息

But console returns the following message

无需更新-您的数据库已经与当前实体元数据同步

Nothing to update - your database is already in sync with the current entity metadata

我使用Symfony 2.1和FOSUserBundle的最新版本.

I use Symfony 2.1 and the last version to FOSUserBundle.

app/AppKernel.php 包含

new FOS\UserBundle\FOSUserBundle(),

app/config/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
    }
}

当我尝试访问我的网站时,出现此错误:

And when I try to access to my website I have this error:

MappingException:在链配置的命名空间FOS \ UserBundle \ Entity,Krpano \ ServicesBundle \ Entity

MappingException: The class 'Krpano\UserBundle\Entity\User' was not found in the chain configured namespaces FOS\UserBundle\Entity, Krpano\ServicesBundle\Entity

你能帮我吗?

推荐答案

无需更新-您的数据库已经与当前实体元数据同步

Nothing to update - your database is already in sync with the current entity metadata

表示由于AppKernel.php中缺少声明而未注册您的实体.

Implies that your entity is not registred because of a missing declaration in AppKernel.php.

Doctrine仅搜索处于活动状态的捆绑软件.

Doctrine only search on bundle who are active.

添加该行之后:

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

您的问题已解决.

我的回答只是对Carlos Granados回答的补充.

My answer is just a completion to Carlos Granados answer.

这篇关于不可能生成表“用户"表.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆