简体   繁体   English

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

[英]symfony The file was found but the class was not in it

when I run this command on my terminal 当我在终端上运行此命令时

php app/console doctrine:schema:validate

I get this error 我得到这个错误

  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.                                                                                 

I using symfony 2.8 and my code like the example page so what's the wrong ? 我使用symfony 2.8和类似示例页面的代码,这是怎么回事?

the product.php file code 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;
  }
}

and the product.orm.yml file 和product.orm.yml文件

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

You need to capitalize your class name: 您需要大写您的班级名称:

class Product

See symfony coding standards here . 请参阅此处的 symfony编码标准。 Specifically, PSR-1 specifies using StudlyCaps for class names. 具体来说, PSR-1指定使用StudlyCaps作为类名。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM