创建 Symfony 5 骨架实体 - 制造商捆绑包不起作用

Creating Symfony 5 skeleton entity - maker bundle not working

我正在尝试 运行

make:entity

但是我收到一个错误:

There are no commands defined in the "make" namespace

You may be looking for a command provided by the "MakerBundle" which is currently not installed. Try running "composer require symfony/maker-bundle --dev"

我遵循该建议并通过以下方式安装捆绑包:

composer require symfony/maker-bundle --dev

安装成功:

然而,当我尝试 运行 make:entity 时,我得到了完全相同的错误:

There are no commands defined in the "make" namespace

You may be looking for a command provided by the "MakerBundle" which is currently not installed. Try running "composer require symfony/maker-bundle --dev"

我错过了什么?

当您 require 使用 --dev 标志的包时,该包将作为开发包安装。

当您的应用程序实际部署时,这些包不应在生产环境中启用。它们必须安装在您的开发机器上,并且只能安装在您的开发机器上。

如果您检查 bundles.php 文件,您会看到这一行:

Symfony\Bundle\MakerBundle\MakerBundle::class    => ['dev' => true],

这确保仅当您的 APP_ENV 变量设置为 dev 时才启用捆绑包。

由于您运行在生产模式下安装您的应用程序,因此未启用捆绑包。

只需将您的 APP_ENV 更改为 dev 以便启用该软件包,您将能够 运行 make 命令。