RuntimeException - 命名空间" Numbers \ Bundle \ NumbersBundle"不包含任何映射实体

时间:2017-01-08 11:37:45

标签: doctrine symfony

要生成我的Symfony实体,我有一些Doctrine模式。例如

src/Numbers/Bundle/NumbersBundle/config/doctrine/Numbers.orm.yml

[更新:也尝试了同样的问题......

src/Numbers/Bundle/NumbersBundle/Resources/config/doctrine/Number.orm.yml ]

我正在跑步:

php bin/console doctrine:generate:entities Numbers/Bundle/NumbersBundle

给出了

Generating entities for namespace "Numbers\Bundle\NumbersBundle"

[RuntimeException]                                                              
Namespace "Numbers\Bundle\NumbersBundle" does not contain any mapped entities.

如果它有助于YML:

# src/Numbers/Bundle/NumbersBundle/Resources/config/doctrine/Numbers.orm.yml
Numbers\Bundle\NumbersBundle\Entity\Number:
  type: entity
  table: numbers
  id:
    id:
      type: integer
      generator: { strategy: AUTO }
  fields:
    value:
      type: integer
      unique: true
    name:
      type: string
      length: 255
      unique: true

有任何建议可能是什么问题,或者如何调试此问题以查看bin/console doctrine:generate:entities正在做什么?

更新

对于-vvv的价值,我得到了这个(虽然似乎没有多大帮助):

php bin/console -vvv doctrine:generate:entities Numbers\Bundle\NumbersBundle
Generating entities for namespace "NumbersBundleNumbersBundle"


[RuntimeException]                                                            
Namespace "NumbersBundleNumbersBundle" does not contain any mapped entities.  


Exception trace:
 () at /Users/snowcrash/numbers/vendor/doctrine/doctrine-bundle/Mapping/DisconnectedMetadataFactory.php:103
 Doctrine\Bundle\DoctrineBundle\Mapping\DisconnectedMetadataFactory->getNamespaceMetadata() at /Users/snowcrash/numbers/vendor/doctrine/doctrine-bundle/Command/GenerateEntitiesDoctrineCommand.php:109
 Doctrine\Bundle\DoctrineBundle\Command\GenerateEntitiesDoctrineCommand->execute() at /Users/snowcrash/numbers/vendor/symfony/symfony/src/Symfony/Component/Console/Command/Command.php:255
 Symfony\Component\Console\Command\Command->run() at /Users/snowcrash/numbers/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php:846
 Symfony\Component\Console\Application->doRunCommand() at /Users/snowcrash/numbers/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php:191
 Symfony\Component\Console\Application->doRun() at /Users/snowcrash/numbers/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Console/Application.php:80
 Symfony\Bundle\FrameworkBundle\Console\Application->doRun() at /Users/snowcrash/numbers/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php:122
 Symfony\Component\Console\Application->run() at /Users/snowcrash/numbers/bin/console:28

doctrine:generate:entities [--path PATH] [--no-backup] [-h|--help] [-q|--quiet] [-v|vv|vvv|--verbose] [-V|--version] [--ansi] [--no-ansi] [-n|--no-interaction] [-e|--env ENV] [--no-debug] [--] <command> <name>

更新2

现在使用更简单的命名空间:

# src/NumbersBundle/Resources/config/doctrine/Number.orm.yml
NumberBundle\Entity\Number:
  type: entity
  table: numbers
  id:
    id:
      type: integer
      generator: { strategy: AUTO }
  fields:
    value:
      type: integer
      unique: true
    name:
      type: string
      length: 255
      unique: true


php bin/console doctrine:generate:entities NumbersBundle
Generating entities for namespace "NumbersBundle"


  [RuntimeException]                                               
  Namespace "NumbersBundle" does not contain any mapped entities. 

文件位于

src/NumbersBundle/Resources/config/doctrine/Number.orm.yml 

并指定实体:

php bin/console doctrine:generate:entities NumbersBundle:Number


  [Doctrine\ORM\ORMException]                      
  Unknown Entity namespace alias 'NumbersBundle'.  

0 个答案:

没有答案