【问题标题】:Symfony 2 no command for generating doctrine crudSymfony 2没有用于生成学说杂物的命令
【发布时间】:2013-05-22 10:02:41
【问题描述】:

我正在尝试为 Symfony 2 中的某些实体生成 CRUD,显然是 generate:doctrine:crud 命令不可用。

  [InvalidArgumentException]                        
  Command "generate:doctrine:crud" is not defined.  

另外,在可用命令列表中,我只得到一个命令。

generate
  generate:doctrine:entities            Generates entity classes and method stubs from your mapping information

配置中是否缺少捆绑包或其他内容,或者没有此功能的原因是什么。

【问题讨论】:

    标签: php symfony doctrine crud


    【解决方案1】:

    加法:

    doctrine:generate:crud 命令由SensioGeneratorBundle提供

    还请确保您有可用的捆绑包并在您的 app/AppKernel.php 中注册,如下所示:

    class AppKernel extends Kernel
    {
        public function registerBundles()
        {
              // ...
        );
    
        if (in_array($this->getEnvironment(), array('dev', 'test'))) {
            // ...
            $bundles[] = new Sensio\Bundle\GeneratorBundle\SensioGeneratorBundle();
            // ...
        }
    

    在我的示例中,该命令通常也仅在开发环境中可用。因此...

    php app/console --env=prod doctrine:generate:crud 
    

    .. 或任何其他使用生产环境的配置都不起作用。

    【讨论】:

      【解决方案2】:

      doctrine:generate:crud 是您应该使用的命令

      您可以使用php app/console list查看命令列表

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多