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

本文是小编为大家收集整理的关于不可能生成 "用户 "表的处理/解决方法,可以参考本文帮助大家快速定位并解决问题,中文翻译不准确的可切换到English标签页查看源文。

问题描述

当我安装 fosuserbundle (官方文档),我尝试使用此命令来生成我的表fos_user:

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

但控制台返回以下消息

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

同步

我使用symfony 2.1和最后一个版本用于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
    }
}

当我尝试访问我的网站时,我有一个错误:

mappingException:在链条配置的名称空间fos \ userbundle \ entity,krpano \ servicesbundle \ entity

你能帮我吗?

推荐答案

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

同步

暗示您的实体没有注册,因为AppKernel.php.

中缺少声明.

仅在活跃的捆绑包上搜索.

添加了行:

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答案的完成.

其他推荐答案

添加

new Krpano\UserBundle\KrpanoUserBundle(),

到您的应用/appkernel.php文件

其他推荐答案

我有这个错误,这是由于意外从我的实体类中删除了@ORM\Entity()行引起的. D'OH.

本文地址:https://www.itbaoku.cn/post/2090809.html

问题描述

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

I use Symfony 2.1 and the last version to FOSUserBundle.

app/AppKernel.php contains

new FOS\UserBundle\FOSUserBundle(),

app/config/config.yml contains

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 contains

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: The class 'Krpano\UserBundle\Entity\User' was not found in the chain configured namespaces FOS\UserBundle\Entity, Krpano\ServicesBundle\Entity

Can you help me?

推荐答案

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

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

Doctrine only search on bundle who are active.

After added the line :

new Krpano\UserBundle\KrpanoUserBundle(),

Like that:

public function registerBundles()
    {
            $bundles = array(    
            ...
            new Krpano\UserBundle\KrpanoUserBundle(),
            new FOS\UserBundle\FOSUserBundle(),    
            ...

        ); ...

Try this:

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

If Doctrine return:

Database schema updated successfully! "1" queries were executed

Your problem is resolve.

My answer is just a completion to Carlos Granados answer.

其他推荐答案

Add

new Krpano\UserBundle\KrpanoUserBundle(),

To your app/AppKernel.php file

其他推荐答案

I had this error and it was caused by having accidentally deleted the @ORM\Entity() line from my entity class. D'oh.