dongzhen4180 2014-06-30 13:43
浏览 35

Symfony2 - “警告:class_parents():Class Ambience不存在且无法加载”

I am trying to create an entity using yml and I am getting the following error:

[ErrorException]

  Warning: class_parents(): Class Ambience does not exist and could not be loaded in C:\wamp\www\demo\vendor\gedmo-doctrine-extensions\lib\Gedmo\Mapping\ExtensionMetadataFactory.php line 80

I have created a file named Entities.UserTestDelete.dcm.yml in FooBundle/Resources/config/doctrine/metadata/orm

Contents of file:

Entities\UserTestDelete:
  type: entity
  table: users
  id:
    id:
      type: integer
      generator:
        strategy: AUTO
  fields:
    name:
      type: string
      length: 50

Then I executed the following command:

php app/console doctrine:mapping:import "DemoFooBundle" yml

And then I got the error. Any idea why would that be a problem?

  • 写回答

2条回答 默认 最新

  • dsbqfrr098575666 2014-06-30 13:50
    关注

    Update
    Your first mistake is that you created the yml file. As explained in the cookbook, the doctrine:mapping:import command actually generates the file. Ditch yours, run the command, and let doctrine generate the file itself.
    What you do afterwards, is generate the actual entity classes:

    php app/console doctrine:mapping:convert annotation ./src
    php app/console doctrine:generate:entities DemoFooBundle
    

    If the tables themselves don't exist yet, then you can use these last 2 commands to generate the entities, and then run

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

    To have doctrine create the tables for you.


    A quick look in the cookbook tells me that the bundle name should not be quoted, and that you might want to pass the --force flag to the doctrine:mapping:import command.
    It's in the reverse-engineering bit

    php app/console doctrine:mapping:import --force DemoFooBundle yml
    

    That's the example Symfony2 cookbook gives, only changed to take yml, instead of xml format.

    The error message could also be related to the table name:

    table: users
    

    Where the entity is called

    class Users
    {}
    

    possible related question

    评论

报告相同问题?

悬赏问题

  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 划分vlan后不通了
  • ¥15 GDI处理通道视频时总是带有白色锯齿
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)
  • ¥15 自适应 AR 模型 参数估计Matlab程序
  • ¥100 角动量包络面如何用MATLAB绘制
  • ¥15 merge函数占用内存过大
  • ¥15 使用EMD去噪处理RML2016数据集时候的原理
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大