doctrine:generate和generate:doctrine之间有多么不同?

时间:2013-09-28 13:48:19

标签: symfony doctrine-orm

我正在使用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

两组之间有什么不同吗?

1 个答案:

答案 0 :(得分:1)

这些命令执行相同的操作:

生成:doctrine:xxx命令

是别名:

doctrine:generate:xxx命令

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

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

  • doctrine:generate:entities :(来自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.')
    
  • doctrine:generate:entity(来自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命令,并且没有doctrine:generate:Generator包中的实体,但它们一起为您提供相关命令的完整列表。没有重新发明轮子。