"There are no commands defined in the 'command' namespace." 在 运行 之后 command:make 在 Laravel

"There are no commands defined in the 'command' namespace." after running command:make in Laravel

就像标题一样。我正在尝试从 artisan

运行
php artisan command:make NameOfCommand

但我只看到

There are no commands defined in the "command" namespace.

知道这是什么吗?

您放错了命令

php artisan make:command NameOfCommand

而不是

php artisan command:make NameOfCommand

如果您只是在命令提示符中输入 php artisan,它会向您显示命令列表,请看一下

在 laravel 5.2 使用 php artisan make:console NameOfCommand

如文档所述(当前版本为 5.2):

Once your command is finished, you need to register it with Artisan so it will be available for use. This is done within the app/Console/Kernel.php file.

在 Kernel.php 文件中,您必须添加: protected $commands = [ Commands\NameOfCommand::class ];

(参考:https://laravel.com/docs/5.2/artisan#registering-commands