Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/257.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 未指定标识符错误Symfony2 ORM映射_Php_Symfony_Orm_Doctrine Orm_Doctrine - Fatal编程技术网

Php 未指定标识符错误Symfony2 ORM映射

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. 手动删除了

当我尝试运行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.
手动删除了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;