2017-03-16 78 views
0

當我在我的終端上運行此命令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 

回答

5

你需要利用你的類名:

class Product 

見symfony的編碼標準here。具體而言,PSR-1指定使用StudlyCaps來獲取類名。

相關問題