Symfony生产映射异常FOSUserBundle


Symfony production Mapping Exception FOSUserBundle

我已经在stackoverflow上搜索了我的问题,但是我没有找到我问题的答案。

目前我正在我的Debian服务器上部署我的symfony项目,运行PHP 5.6.26,遵循symfony网站上的文档。

当我通过运行命令来安装我的bundle时composer install --no-dev --optimize-autoloader

我得到以下错误:

[学说' ORM映射' ' MappingException]"FOS'UserBundle'Model'User"的子类"AppBundle'Entity'User"不是一个有效的实体或映射的超类。

我的开发机器(Windows 10台式机和Macbook)没有出现此错误

目前我不知道什么可能是错的。在项目后期,我确实从注释切换到yml。

我的User.php文件:

<?php
namespace AppBundle'Entity;
use FOS'UserBundle'Model'User as BaseUser;
/**
 * User
 */
class User extends BaseUser
{
    public function __construct()
    {
        parent::__construct();
    }
    protected $id;
    /**
     * @var 'AppBundle'Entity'Address
     */
    private $address;

    /**
     * Set address
     *
     * @param 'AppBundle'Entity'Address $address
     *
     * @return User
     */
    public function setAddress('AppBundle'Entity'Address $address = null)
    {
        $this->address = $address;
        return $this;
    }
    /**
     * Get address
     *
     * @return 'AppBundle'Entity'Address
     */
    public function getAddress()
    {
        return $this->address;
    }
}

和我的User.orm.yml文件:

AppBundle'Entity'User:
    type: entity
    table: user
    repositoryClass: AppBundle'Repository'UserRepository
    id:
        id:
            type: integer
            id: true
            generator:
                strategy: AUTO
    lifecycleCallbacks: {  }
    oneToOne:
      address:
        targetEntity: AppBundle'Entity'Address
        cascade: ["persist", "remove"]

我不是100%确定,但我在这里看到一个说明,user是一个保留的SQL关键字,你可能需要改变你的src/AppBundle/Resources/config/doctrine/User.orm.yml文件,像这样:

AppBundle'Entity'User:
    type: entity
    table: fos_user

你能试着看看这是否有效吗?

看到Alvin Bunk的回答后,我看到他的回答中Resources文件夹(在src/AppBundle中)是大写的。检查后,我的文件夹资源没有大写。

我的修复:大写文件夹资源src/AppBundle/