Php 未指定标识符错误Symfony2 ORM映射
当我尝试运行php app/config doctor:schema:update-force或只是在web浏览器中同步打开我的项目时,我会遇到以下错误:Php 未指定标识符错误Symfony2 ORM映射,php,symfony,orm,doctrine-orm,doctrine,Php,Symfony,Orm,Doctrine Orm,Doctrine,当我尝试运行php app/config doctor:schema:update-force或只是在web浏览器中同步打开我的项目时,我会遇到以下错误: MappingException: No identifier/primary key specified for Entity "Registration\BusinessBundle\Entity\BusinessUser". Every Entity must have an identifier/primary key. 手动删除了
MappingException: No identifier/primary key specified for Entity "Registration\BusinessBundle\Entity\BusinessUser". Every Entity must have an identifier/primary key.
手动删除了app/cache文件夹,但问题仍然存在。如果我试图通过命令php-app/console-cache:clear删除缓存,我会得到相同的错误
业务用户实体:
<?php
namespace Registration\BusinessBundle\Entity;
//use FOS\UserBundle\Model\User as BaseUser;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity
* @ORM\Table(name="business_user")
*/
class BusinessUser
{
/*
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
/*
* @ORM\Column(type="string", length=255)
*/
protected $surname;
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set surname
*
* @param string $surname
* @return BusinessUser
*/
public function setSurname($surname)
{
$this->surname = $surname;
return $this;
}
/**
* Get surname
*
* @return string
*/
public function getSurname()
{
return $this->surname;
}
}
在使用条令注释的地方,您的实体不包含PHP docblock注释 DockBlock是带有两个星号的startet,否则它只是一个简单的注释 更改您当前的代码
/*
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
到
只有使用/**注释才能被原则认可
同时检查您的其他属性。尝试将id列的策略从“自动”更改为“标识”。这不会造成任何更改。
/**
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;