我正在尝试遵循官方的Symfony手册(只是表的名称不同),并希望将我的数据库表与实体映射。我创建了一个基于(复制/粘贴 URL 和文件名,因此不可能有拼写错误)的类:
C:\xampp\htdocs\goodstuff\src\AppBundle\Entity\Customer.php
类文件的源代码:
namespace AppBundleEntity;
use DoctrineORMMapping as ORM;
/**
* @ORMEntity
* @ORMTable(name="customer")
*/
class Customer
{
/**
* @ORMColumn(type="integer")
* @ORMId
* @ORMGeneratedValue(strategy="AUTO")
*/
protected $id;
/**
* @ORMColumn(type="string", length=255)
*/
protected $first_name;
/**
* @ORMColumn(type="string", length=255)
*/
protected $last_name;
/**
* @ORMColumn(type="string", length=255)
*/
protected $mid_name;
/**
* @ORMColumn(type="string", length=100)
*/
protected $phone;
/**
* @ORMColumn(type="string", length=100)
*/
protected $email;
/**
* @ORMColumn(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:xampphtdocsgoodstuff>....phpphp appconsole doctrine:generate:entities AppBundle/Entity/Customer
namespace AppBundleEntity;
use DoctrineORMMapping as ORM;
/**
* @ORMEntity
* @ORMTable(name="customer")
*/
class Customer
{
/**
* @ORMColumn(type="integer")
* @ORMId
* @ORMGeneratedValue(strategy="AUTO")
*/
protected $id;
/**
* @ORMColumn(type="string", length=255)
*/
protected $first_name;
/**
* @ORMColumn(type="string", length=255)
*/
protected $last_name;
/**
* @ORMColumn(type="string", length=255)
*/
protected $mid_name;
/**
* @ORMColumn(type="string", length=100)
*/
protected $phone;
/**
* @ORMColumn(type="string", length=100)
*/
protected $email;
/**
* @ORMColumn(type="string", length=1000)
*/
protected $comments;
}
[RuntimeException]
The autoloader expected class "AppBundleEntityCustomer" to be defined in file "C:xampphtdocsgoodstuff/srcAppBundleEntityCustomer.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
只使用您的捆绑包名称进行尝试。那行得通吗?
php app/console doctrine:generate:entities AppBundle
或者尝试使用 --path 属性,如语法所述:
doctrine:generate:entities [--path="..."] [--no-backup] name