1

我正在使用Doctrine2来管理我的数据库。当我列出所有 Doctrine2 命令时,我想知道为什么有两种解释相同的命令:

generate:doctrine:crud                Generates a CRUD based on a Doctrine entity
generate:doctrine:entities            Generates entity classes and method stubs from yourmapping information
generate:doctrine:entity              Generates a new Doctrine entity inside a bundle
generate:doctrine:form                Generates a form type class based on a Doctrine entity

doctrine:generate:crud                Generates a CRUD based on a Doctrine entity
doctrine:generate:entities            Generates entity classes and method stubs from your mapping information
doctrine:generate:entity              Generates a new Doctrine entity inside a bundle
doctrine:generate:form                Generates a form type class based on a Doctrine entity

两组之间有什么不同吗?

4

1 回答 1

1

这些命令做同样的事情:

生成:学说:xxx 命令

是的别名:

学说:生成:xxx 命令

它们实现了相同的目标,并且可以互换使用。

如果您查看这两个命令的源代码,您会发现更多信息:

  • 学说:生成:实体:(来自 Doctrine\Bundle\DoctrineBundle )

       $this
        ->setName('doctrine:generate:entities')
        ->setAliases(array('generate:doctrine:entities'))
        ->setDescription('Generates entity classes and method stubs from your mapping information')
        ->addArgument('name', InputArgument::REQUIRED, 'A bundle name, a namespace, or a class name')
        ->addOption('path', null, InputOption::VALUE_REQUIRED, 'The path where to generate entities when it cannot be guessed')
        ->addOption('no-backup', null, InputOption::VALUE_NONE, 'Do not backup existing entities files.')
    
  • 学说:生成:实体(来自 Sensio\Bundle\Generator 捆绑包)

        $this
        ->setName('doctrine:generate:entity')
        ->setAliases(array('generate:doctrine:entity'))
        ->setDescription('Generates a new Doctrine entity inside a bundle')
        ->addOption('entity', null, InputOption::VALUE_REQUIRED, 'The entity class name to initialize (shortcut notation)')
        ->addOption('fields', null, InputOption::VALUE_REQUIRED, 'The fields to create with the new entity')
        ->addOption('format', null, InputOption::VALUE_REQUIRED, 'Use the format for configuration files (php, xml, yml, or annotation)', 'annotation')
        ->addOption('with-repository', null, InputOption::VALUE_NONE, 'Whether to generate the entity repository or not')
    

看起来上面的两个捆绑包相互完成。即DoctrineBundle 中没有doctrine:generate:entity 命令,Generator 包中也没有doctrine:generate:entities,但它们一起为您提供了相关命令的完整列表。没有重新发明轮子。

于 2013-09-28T14:34:40.410 回答