symfony的文件已找到,但这个类是不是在它

问题描述:

当我在我的终端上运行此命令symfony的文件已找到,但这个类是不是在它

php app/console doctrine:schema:validate 

我得到这个错误

The autoloader expected class "tuto\testBundle\Entity\product" to be defined in file "../src/tuto/testBundle/Entity/product.php". The file was found but the class was not in it, the class name or names 
    pace probably has a typo.                     

我使用symfony的2.8和我的代码,如示例页面,所以错在哪里?

的product.php文件代码

<?php 
namespace AppBundle\Entity; 
use Doctrine\ORM\Mapping as ORM; 


/** 
* @ORM\Entity 
* @ORM\Table(name="product") 
*/ 
class product 
{ 


    /** 
    *@ORM\Column(type="integer") 
    *@ORM\Id 
    *@ORM\GeneratedValue(strategy="AUTO") 
    */ 


    private $id; 
    /** @ORM\Column(length=140) */ 




    public function getUserId(){ 
    return $this->UserId; 
    } 
    public function setUserId($id){ 
    return $this->UserId=$id; 
    } 
} 

和product.orm.yml文件

AppBundle\Entity\product: 
    type: entity 
    table: product 
    id: 
    id: 
     type: integer 
     generator: 
     strategy: AUTO 

你需要利用你的类名:

class Product 

见symfony的编码标准here。具体而言,PSR-1指定使用StudlyCaps来获取类名。