首页 文章

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

提问于
浏览
3

我想在src / Acme / AdminBundle / Entity / Artist.orm.yml中添加像 just 这样的项目:

email:
  type: string
  column: email_address
  length: 150

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

/**
 * @var string $email
 */
private $email;

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

php app/console doctrine:schema:update --force

[学说\ ORM \映射\ MappingException]
Acme \ AdminBundle \ Entity \ Artist中发生错误

[ReflectionException]
properties 电子邮件不存在

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

2 回答

  • 8

    首先,生成实体类文件

    php app/console doctrine:generate:entities [Your]/[Bundle]/Entity/Artist --path="src/" --no-backup
    

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

    然后,更新您的架构:

    php app/console doctrine:schema:update --force
    
  • 2

    我有同样的问题,我设法解决它 .

    doctrine:generate:entity在“Entity”生成.php实体文件,但它也会在“Resources / config / doctrine”生成一个orm文件,如果你修改.php实体文件,它会产生冲突 .

    我刚刚删除了orm文件,它按预期工作 .

相关问题