【发布时间】:2015-03-12 13:19:35
【问题描述】:
我正在尝试遵循 Symfony 官方手册(只是表的名称不同)并希望将我的数据库表与实体映射。我创建了一个基于(复制/粘贴 URL 和文件名,所以拼写错误)的类:
C:\xampp\htdocs\goodstuff\src\AppBundle\Entity\Customer.php
类文件源代码:
namespace AppBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity
* @ORM\Table(name="customer")
*/
class Customer
{
/**
* @ORM\Column(type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
/**
* @ORM\Column(type="string", length=255)
*/
protected $first_name;
/**
* @ORM\Column(type="string", length=255)
*/
protected $last_name;
/**
* @ORM\Column(type="string", length=255)
*/
protected $mid_name;
/**
* @ORM\Column(type="string", length=100)
*/
protected $phone;
/**
* @ORM\Column(type="string", length=100)
*/
protected $email;
/**
* @ORM\Column(type="string", length=1000)
*/
protected $comments;
}
然后我运行命令:
c:\xampp\htdocs\goodstuff>....\php\php app\console octrine:generate:entities AppBundle/Entity/Customer
或
c:\xampp\htdocs\goodstuff>....\php\php app\console octrine:generate:entities AppBundle\Entity\Customer
在这两种情况下,我都会收到相同的错误消息:
c:\xampp\htdocs\goodstuff>..\..\php\php app\console doctrine:generate:entities AppBundle/Entity/Customer
namespace AppBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity
* @ORM\Table(name="customer")
*/
class Customer
{
/**
* @ORM\Column(type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
/**
* @ORM\Column(type="string", length=255)
*/
protected $first_name;
/**
* @ORM\Column(type="string", length=255)
*/
protected $last_name;
/**
* @ORM\Column(type="string", length=255)
*/
protected $mid_name;
/**
* @ORM\Column(type="string", length=100)
*/
protected $phone;
/**
* @ORM\Column(type="string", length=100)
*/
protected $email;
/**
* @ORM\Column(type="string", length=1000)
*/
protected $comments;
}
[RuntimeException]
The autoloader expected class "AppBundle\Entity\Customer" to be defined in file "C:\xampp\htdocs\goodstuff/src\AppBundle\Entity\Customer.php". The file was found but the class was not in it, the class name or namespace probab ly has a typo.
doctrine:generate:entities [--path="..."] [--no-backup] name
【问题讨论】:
-
你能用缺少的错误信息编辑你的问题吗?
-
@Veve 我已经修改了
标签: php mysql symfony doctrine-orm