【问题标题】:Entity class not found when trying to create entities from yml config files尝试从 yml 配置文件创建实体时找不到实体类
【发布时间】:2012-01-22 23:29:05
【问题描述】:

我正在尝试创建实体类。我正在使用 Resources/config/doctrine 文件夹中的 yml 文件。

Category.orm.yml

Marek\JobeetBundle\Entity\Category:
  type: entity
  table: null
  fields:
    id:
      type: integer
      id: true
      generator:
        strategy: IDENTITY
    name:
      type: string
      length: '255'
      unique: true
  manyToMany:
  affiliates:
    targetEntity: Marek\JobeetBundle\Entity\Affiliate
    joinTable:
      name: CategoryAffiliate
      joinColumns:
        category_id:
          referencedColumnName: id
      inverseJoinColumns:
        affiliate_id:
          referencedColumnName: id
  lifecycleCallbacks: {  }

Affilate.orm.yml

Marek\JobeetBundle\Entity\Affiliate:
  type: entity
  table: null
  fields:
    id:
      type: integer
      id: true
      generator:
        strategy: IDENTITY
    url:
      type: string
      length: '255'
      nullable: true
    email:
      type: string
      length: '255'
      nullable: true
      unique: true
    token:
      type: string
      length: '255'
    isActive:
      type: boolean
      nullable: false
      column: is_active
      default: 0
    createdAt:
      type: datetime
      column: created_at
      gedmo:
        timestampable:
          on: create
  manyToMany:
  categories:
    targetEntity: Marek\JobeetBundle\Entity\Category
    mappedBy: affiliates
  lifecycleCallbacks: {  }

工作:

Marek\JobeetBundle\Entity\Job:
  type: entity
  table: null
  fields:
    id:
      type: integer
      id: true
      generator:
        strategy: IDENTITY
    type:
      type: string
      length: '255'
    company:
      type: string
      length: '255'
      nullable: true
    logo:
      type: string
      length: '255'
    url:
      type: string
      length: '255'
      nullable: true
    position:
      type: string
      length: '255'
      nullable: true
    location:
      type: string
      length: '255'
    description:
      type: string
      length: '4000'
    howToApply:
      type: string
      length: '4000'
      column: how_to_apply
    token:
      type: string
      length: '255'
      unique: true
    isPublic:
      type: boolean
      length: null
      column: is_public
    isActivated:
      type: boolean
      length: null
      column: is_activated
    email:
      type: string
      length: '255'
    createdAt:
      type: datetime
      column: created_at
      gedmo:
        timestampable:
          on: create
    updatedAt:
      type: datetime
      column: updated_at
      gedmo:
        timestampable:
          on: update
    expiresAt:
      type: datetime
      column: expires_at
  oneToOne:
    category:
      targetEntity: Marek\JobeetBundle\Entity\Category
      cascade: {  }
      mappedBy: null
      inversedBy: null
      joinColumns:
        category_id:
          referencedColumnName: id
      orphanRemoval: false
  lifecycleCallbacks: {  }

执行后:

php 应用程序/控制台原则:generate:entities JobeetBundle --path="src"

我得到:

警告:class_parent(): Class Marek\JobeetBundle\Entity\Affiliate 不存在且无法加载 供应商/gedmo-doctrine-extension\lib\Gedmo\Mapping\ExtensionMetadataFactory.php 在第 80 行。

我知道我没有任何要创建的实体。

有人可以帮忙吗?

【问题讨论】:

    标签: symfony doctrine-orm


    【解决方案1】:

    这可能是由 Gedmo 中的无效假设引起的。尝试在 config.yml 中注释掉整个 stof_doctrine_extensions 块,然后运行生成命令。如果它有效,您应该能够取消注释配置并重新开始工作。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-09-28
      • 2018-06-08
      • 2018-11-27
      • 2012-02-26
      • 2019-05-10
      • 1970-01-01
      • 2013-08-30
      相关资源
      最近更新 更多