Symfony2 Jobeet tutorial day 3 error invalid mapping

这一生的挚爱 提交于 2019-12-23 19:43:24

问题


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 ]

回答1:


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.




回答2:


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



来源:https://stackoverflow.com/questions/16624324/symfony2-jobeet-tutorial-day-3-error-invalid-mapping

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!