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

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/47916628/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 02:36:06  来源:igfitidea点击:

Symfony there are no commands defined in the "make" namespace

phpsymfonyterminaldoctrine-odm

提问by lola_the_coding_girl

Following the documentation found hereI enter php bin/console make:entity Productin Terminal and get the following error:

按照此处找到的文档php bin/console make:entity Product在终端中输入并收到以下错误:

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

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

回答by sensorario

makeis a command of doctrine component. Just add doctrine maker.

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

composer require doctrine maker

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

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

回答by flu

Maybe you where using the prodenvironment?

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

The website-skeletonputs the Maker Bundle in the require-devsection of your composer.jsonby default:

默认情况下,website-skeleton将 Maker Bundle 放在require-dev您的部分composer.json

"require-dev": {
    ...
    "symfony/maker-bundle": "^1.0",
    ...
}

If you've set APP_ENV=prodin your .envfile and ran bin/consoleit would ignore all devrequirements and thus wouldn't enable the Maker Bundle.

如果您已APP_ENV=prod.env文件中进行设置并运行bin/console,它将忽略所有dev要求,因此不会启用 Maker Bundle

Simply enabling the devenvironment again (APP_ENV=dev) would do the trick then.

只需dev再次启用环境 ( APP_ENV=dev) 就可以解决问题。

回答by Oleg Kyryliv

try

尝试

composer remove maker
composer require maker --dev

and then

进而

php bin/console make:entity Product

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

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

回答by Marcos Labad

You need Symfony 3.4 or higher. For Symfony 3.4 you will need to add it to the registerBundles function in config/AppKernerl():

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

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

Bear in mind that the environment where it is installed is 'dev'.

请记住,安装它的环境是“dev”。

回答by atef zoiaidi

Try composer require symfony/maker-bundle --devit work for me.

试试composer require symfony/maker-bundle --dev它对我有用。

回答by Akiro

You must define the "dev" env in the command line :

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

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

回答by O.Ndiaye

If you have installed symfony / maker-bundle for the dev mode you will only be able to use it for this mode. If you are in prod mode then go to dev mode and try again

如果您为开发模式安装了 symfony / maker-bundle,您将只能在此模式下使用它。如果您处于生产模式,请转到开发模式并重试

回答by Paul

The objective is go to dev mode to be able to make an entity. To do so : export SYMFONY_ENV=dev

目标是进入开发模式以能够创建实体。这样做: export SYMFONY_ENV=dev

If it still does not work, like it was the case for me, you can try : php bin/console cache:clear

如果它仍然不起作用,就像我的情况一样,您可以尝试: php bin/console cache:clear

Then you will be able to run : php bin/console make:entity

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