因此,我正在尝试关注symfony2's tutorial on doctrine我自己的网站,并在User
个Product
实体后对其进行建模。
此外,在任何人将此标记复制之前,我已经尝试过在许多其他问题中给出的解决方案而没有运气:
并且列表继续
我有我的实体类:
<?php
namespace MySite\MyBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity
* @ORM\Table(name="user")
*/
class User
{
/**
* @ORM\Column(type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
/**
* @ORM\Column(type="string", length=100)
*/
protected $name;
/**
* @ORM\Column(type="string", length=64)
*/
protected $password;
}
?>
现在,我正在运行命令:
$ php app/console doctrine:generate:entities MySite/MyBundle/Entity/User
生成存取方法。但是,当我这样做时,我收到错误:
[Doctrine\ORM\Mapping\MappingException]
Class "MySite\MyBundle\Entity\User" is not a valid entity or mapped super class.
答案 0 :(得分:4)
好的,我自己弄清楚了。我的问题是我的config.yml错了。我错过了config.yml中的auto_mapping: true
行。
doctrine:
# (dbal stuff here)
orm:
auto_generate_proxy_classes: "%kernel.debug%"
auto_mapping: true
添加后,所有内容都会使用php app/console doctrine:generate:entities MySite/MyBundle/Entity/User
行
答案 1 :(得分:0)
我有一个类似的问题,我最后发现我的案例中的问题是我错过了扩展Bundle的课程
namespace Acme\TagBundle;
use Symfony\Component\HttpKernel\Bundle\Bundle;
class AcmeTagBundle extends Bundle
{
}
并在bundle数组下声明AppKernel.php中的类。
答案 2 :(得分:0)
我的问题是我将文件夹实体命名为Entity。当我修复它时,它就像一个魅力。