When I generate bundle entities with code

php app/console doctrine:generate:entities EnsJobeetBundle

I'm getting this error

[Doctrine\Common\Persistence\Mapping\MappingException] Invalid mapping file 'Ens.JobeetBundle.Entity.Affiliate.orm.yml' for class 'Ens\JobeetBundle\Entity\Affiliate'.

This is Affiliate.orm.yml file:

 Ens\JobeetBundle\Entity\Affiliate:
  type: entity
  table: affiliate
  id:
    id:
      type: integer
      generator: { strategy: AUTO }
  fields:
    url:
      type: string
      length: 255
    email:
      type: string
      length: 255
      unique: true
    token:
      type: string
      length: 255
    created_at:
      type: datetime
  oneToMany:
    category_affiliates:
      targetEntity: CategoryAffiliate
      mappedBy: affiliate
  lifecycleCallbacks:
    prePersist: [ setCreatedAtValue ]
有帮助吗?

解决方案

Try opening the file in a text editor, and replacing " " with " " globally.

My colleague was having the exact same issue on the same file, and it turns out the problem was that the file was using something other than spaces as spaces. file(1) showed that the file was a UTF-8 Unicode text rather than plain ASCII.

I believe this may be caused by the source of the copy + paste using different space characters.

其他提示

This yaml .yml configuration files cannot contain TABs. Only spaces as intendation. That is the problem.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top