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
Symfony there are no commands defined in the "make" namespace
提问by lola_the_coding_girl
Following the documentation found hereI enter php bin/console make:entity Product
in 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
make
is 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 prod
environment?
也许你在哪里使用prod
环境?
The website-skeleton
puts the Maker Bundle in the require-dev
section of your composer.json
by default:
默认情况下,website-skeleton
将 Maker Bundle 放在require-dev
您的部分composer.json
:
"require-dev": {
...
"symfony/maker-bundle": "^1.0",
...
}
If you've set APP_ENV=prod
in your .env
file and ran bin/console
it would ignore all dev
requirements and thus wouldn't enable the Maker Bundle.
如果您已APP_ENV=prod
在.env
文件中进行设置并运行bin/console
,它将忽略所有dev
要求,因此不会启用 Maker Bundle。
Simply enabling the dev
environment 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 --dev
it 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