Php Symfony生产映射异常FOSUserBundle
我在stackoverflow上搜索了我的问题,但没有找到我问题的答案 目前,我正在运行PHP5.6.26的Debian服务器上部署我的symfony项目 当我通过运行命令来执行安装捆绑包的命令时Php Symfony生产映射异常FOSUserBundle,php,symfony,doctrine-orm,fosuserbundle,Php,Symfony,Doctrine Orm,Fosuserbundle,我在stackoverflow上搜索了我的问题,但没有找到我问题的答案 目前,我正在运行PHP5.6.26的Debian服务器上部署我的symfony项目 当我通过运行命令来执行安装捆绑包的命令时 composer安装--无开发--优化自动加载程序 我得到以下错误: [条令\ORM\Mapping\MappingException] “FOS\UserBundle\Model\User”的类“AppBundle\Entity\User”子类不是有效的实体或映射的超类 我的开发机器(Windows
composer安装--无开发--优化自动加载程序
我得到以下错误:
[条令\ORM\Mapping\MappingException]
“FOS\UserBundle\Model\User”的类“AppBundle\Entity\User”子类不是有效的实体或映射的超类
我的开发机器(Windows 10桌面和Macbook)上没有此错误
目前我还不知道会出什么问题。在项目后期,我确实从annotation切换到了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;
}
}
我不是100%确定,但我认为
user
是一个保留的SQL关键字,您可能需要更改src/AppBundle/Resources/config/doctor/user.orm.yml
文件,如下所示:
AppBundle\Entity\User:
type: entity
table: fos_user
你能试试看这是否有效吗?
虽然我不确定,但是试试看。在看到Alvin Bunk的答案后,我看到文件夹资源(在src/AppBundle中)在他的答案中是大写的。 检查后,我的文件夹资源未大写
我的解决方案:将
src/AppBundle/
中的文件夹Resources大写。我将表名更改为fos\u user。但这不起作用,我想您已经编辑了app/AppKernel.php
以包含FOSUserBundle。否则,我想不出还有什么。这应该是相当直截了当的。我在你的回答中看到文件夹资源是大写的。我的文件夹资源(在src/AppBundle中)不可用,更改后,我的项目已启动并运行!谢谢好消息!很高兴你明白了
AppBundle\Entity\User:
type: entity
table: fos_user