symfony找到该文件,但该类不在其中
问题描述:
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 ?
the product.php file code
<?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
AppBundle\Entity\product:
type: entity
table: product
id:
id:
type: integer
generator:
strategy: AUTO
当我在终端上运行此命令时 p>
php app / console doctrine:schema:validate
code> pre>
我收到此错误 p>
自动加载器预期类“tuto \ testBundle \ Entity \ product“将在文件中定义”../src/tuto/testBundle/Entity/product.php“。 找到了该文件,但是该类不在其中,类名或名称
步长可能有拼写错误。
code> pre>
我使用symfony 2.8和我的代码如示例页面那么有什么不对? p>
product.php文件代码 p>
&lt;?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)* /
公共函数getUserId(){
返回$ this-&gt; UserId;
}
公共函数setUserId($ id){
return $ this-&gt; UserId = $ id;
}
}
code> pre>
和product.orm.yml文件 p>
AppBundle \ Entity \ product :
type:entity
table:product
id:
id:
type:integer
generator:
strategy:AUTO
code> pre>
div>