symfony找到该文件,但该类不在其中

mrs*_*rko 0 php symfony

当我在终端上运行此命令时

php app/console doctrine:schema:validate
Run Code Online (Sandbox Code Playgroud)

我收到这个错误

  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.                                                                                 
Run Code Online (Sandbox Code Playgroud)

我使用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;
  }
}
Run Code Online (Sandbox Code Playgroud)

和product.orm.yml文件

AppBundle\Entity\product:
  type: entity
  table: product
  id:
    id:
      type: integer
      generator:
        strategy: AUTO
Run Code Online (Sandbox Code Playgroud)

ehy*_*mel 5

您需要将您的班级名称大写:

class Product
Run Code Online (Sandbox Code Playgroud)

请参阅此处的 symfony编码标准.具体来说,PSR-1指定使用StudlyCaps作为类名.