仅使用Doctrine从Symfony2中的yml更新模式

Sad*_*iel 3 symfony doctrine-orm

我想这样的添加项目只是到src/Acme的/ AdminBundle /实体/ Artist.orm.yml:

email:
  type: string
  column: email_address
  length: 150
Run Code Online (Sandbox Code Playgroud)

但我不得不在文件Acme/AdminBundle/Entity/Artist中做同样的事情

/**
 * @var string $email
 */
private $email;
Run Code Online (Sandbox Code Playgroud)

如果我不这样做,当我更新架构时它会显示错误:

php app/console doctrine:schema:update --force
Run Code Online (Sandbox Code Playgroud)

[Doctrine\ORM\Mapping\MappingException]
Acme\AdminBundle\Entity\Artist出错

[ReflectionException]
属性电子邮件不存在

我在开头使用yml选项生成了Bundle.

Éci*_*lva 8

首先,生成实体类文件

php app/console doctrine:generate:entities [Your]/[Bundle]/Entity/Artist --path="src/" --no-backup
Run Code Online (Sandbox Code Playgroud)

如果要生成新实体,则必须给出"--path"参数.

然后,更新您的架构:

php app/console doctrine:schema:update --force
Run Code Online (Sandbox Code Playgroud)