Symfony没有在“make”命名空间中定义的命令

时间:2017-12-21 01:24:31

标签: php symfony terminal doctrine-odm

根据找到的文档here,我在终端中输入php bin/console make:entity Product并收到以下错误:

[Symfony\Component\Console\Exception\CommandNotFoundException]
There are no commands defined in the "make" namespace.

11 个答案:

答案 0 :(得分:14)

make是教义组成部分的命令。只需添加学说制作者。

composer require doctrine maker

https://symfony.com/doc/current/doctrine.html#installing-doctrine

答案 1 :(得分:7)

尝试

composer remove maker
composer require maker --dev

然后

php bin/console make:entity Product

https://symfony.com/doc/current/bundles/SymfonyMakerBundle/index.html

答案 2 :(得分:5)

也许您在哪里使用prod环境?

默认情况下,website-skeleton将制作工具包放入require-dev的{​​{1}}部分:

composer.json

如果您在"require-dev": { ... "symfony/maker-bundle": "^1.0", ... } 文件中设置了APP_ENV=prod并运行了.env,它将忽略所有bin/console的要求,因此将不会启用Maker Bundle

然后再次启用dev环境(dev)就可以解决问题。

答案 3 :(得分:4)

您需要Symfony 3.4或更高版本。对于Symfony 3.4,您需要将它添加到config / AppKernerl()中的registerBundles函数中:

            if (in_array($this->getEnvironment(), array('dev', 'test'))) {
            // [...]
            $bundles[] = new \Symfony\Bundle\MakerBundle\MakerBundle();
        }

请记住安装它的环境是'dev'。

答案 4 :(得分:1)

您必须在命令行中定义“ dev”环境:

php bin/console --env dev
php bin/console make:entity Product --env dev

答案 5 :(得分:1)

问题刚发生在我身上。 我在测试环境中。 您必须处于开发环境中。

检查.env文件中的APP_ENV值。必须是以下内容:

APP_ENV=dev

答案 6 :(得分:1)

我认为您处于生产环境中。检查.env文件中APP_ENV的值是否不等于prod。

如果生成.env.local文件,则必须在开发环境中将其删除。

答案 7 :(得分:0)

如果您为开发人员模式安装了symfony / maker-bundle,则只能在此模式下使用它。如果你在  生产模式,然后进入开发模式,然后重试

答案 8 :(得分:0)

目标是进入开发人员模式才能成为一个实体。为此: export SYMFONY_ENV=dev

如果仍然无法正常工作(例如我的情况),可以尝试: php bin/console cache:clear

然后您将能够运行: php bin/console make:entity

答案 9 :(得分:0)

尝试“ composer require symfony / maker-bundle --dev”对我有用

答案 10 :(得分:0)

composer require symfony/maker-bundle --dev