开发者

YAML Mapping exception on Doctrine 2

I created my database and tables using phpMyAdmin. I setup the relations there aswell.

I then wanted to get Doctrine 2 to create the YAML files for me by do this command:

php doctrine orm:convert-mapping --from-database yml /path/to/fixtures/schema

And it created the *.dcm.yml files and looks ok. So I needed to make entities by doing this:

php doctrine orm:generate-entities /path/to/models

I get this error however:

[Doctrine\ORM\Mapping\MappingException] Class Callers\dcm is not a valid entity or mapped super class.

I added the -v flag and got this:

Exception trace: () at /Users/me/Sites/project/modules/doctrine2/classes/doctrine/Doctrine/ORM/Mapping/MappingException.php:137 Doctrine\ORM\Mapping\MappingException::classIsNotAValidEntityOrMappedSuperClass() at /Users/me/Sites/project/modules/doctrine2/classes/doctrine/Doctrine/ORM/Mapping/Driver/YamlDriver.php:55 Doctrine\ORM\Mapping\Driver\YamlDriver->loadMetadataForClass() at /Users/me/Sites/project/modules/doctrine2/classes/doctrine/Doctrine/ORM/Mapping/ClassMetadataFactory.php:282 Doctrine\ORM\Mapping\ClassMetadataFactory->loadMetadata() at /Users/me/Sites/project/modules/doctrine2/classes/doctrine/Doctrine/ORM/Mapping/ClassMetadataFactory.php:176 Doctrine\ORM\Mapping\ClassMetadataFactory->getMetadataFor() at /Users/me/Sites/project/modules/doctrine2/classes/doctrine/Doctrine/ORM/Mapping/ClassMetadataFactory.php:123 Doctrine\ORM\Mapping\ClassMetadataFactory->getAllMetadata() at /Users/me/Sites/project/modules/doctrine2/classes/doctrine/Doctrine/ORM/Tools/Console/Command/GenerateEntitiesCommand.php:101 Doctrine\ORM\Tools\Console\Command\GenerateEntitiesCommand->execute() at /Users/me/Sites/project/modules/doctrine2/classes/doctrine/Doctrine/Symfony/Component/Console/Command/Command.php:150 Symfony\Component\Console\Command\Command->run() at /Users/me/Sites/project/modules/doctrine2/classes/doctrine/Doctrine/Symfony/Component/Console/Application.php:187 Symfony\Component\Console\Application->doRun() at /Users/me/Sites/project/modules/doctrine2/classes/doctrine/Doctrine/Symfony/Component/Console/Application.php:113 Symfony\Component\Console\Application->run() at /Users/me/Sites/project/modules/doctrine2/bin/doctrine.php:40 include() at /Users/me/Sites/project/modules/doctrine2/bin/doctrine:4

I am trying to get Doctrine 2 to work with MySQL relationships as a module of Kohana. Thought I would start with getting Doctrine to work as that's r开发者_运维问答eally the harder part.

Here is the YAML file it created:

Callers:
  type: entity
  table: callers
  fields:
    id:
      id: true
      type: integer
      unsigned: false
      nullable: false
      generator:
        strategy: AUTO
    firstname:
      type: string
      length: 75
      fixed: false
      nullable: true
    lastname:
      type: string
      length: 75
      fixed: false
      nullable: true
    company:
      type: string
      length: 75
      fixed: false
      nullable: true
    email:
      type: string
      length: 150
      fixed: false
      nullable: true
    datecreated:
      type: datetime
      nullable: false
    dateupdated:
      type: datetime
      nullable: false
    address1:
      type: string
      length: 150
      fixed: false
      nullable: true
    address2:
      type: string
      length: 150
      fixed: false
      nullable: true
    city:
      type: string
      length: 100
      fixed: false
      nullable: true
    state:
      type: string
      length: 50
      fixed: false
      nullable: true
    zip:
      type: string
      length: 10
      fixed: false
      nullable: true

So what is going wrong?


I just had a similar error happen to me. Make sure your .dcm.yml file is named Callers.dcl.yml and not callers.dcl.yml. The upper case first letter is important and must match your class name.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜