php “'command' 命名空间中没有定义任何命令。” 运行命令后:在 Laravel 中制作

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/32396158/
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-25 22:57:04  来源:igfitidea点击:

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

phplaravelartisan

提问by Zbigniew Kis?y

Just like in title. I'm trying to run from artisan

就像标题一样。我试图逃避工匠

php artisan command:make NameOfCommand

but all I see is

但我所看到的是

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

Any idea what is this?

知道这是什么吗?

回答by Alejandro Silva

As the documentation says (Current version is 5.2 at this moment):

正如文档所说(当前版本为 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.

命令完成后,您需要在 Artisan 中注册它,以便它可以使用。这是在 app/Console/Kernel.php 文件中完成的。

in the Kernel.php file you must add: protected $commands = [ Commands\NameOfCommand::class ];

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

(ref: https://laravel.com/docs/5.2/artisan#registering-commands)

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

回答by Narendrasingh Sisodia

You have misplaced the command it is

你放错了命令

php artisan make:command NameOfCommand

and not

并不是

php artisan command:make NameOfCommand

If you have simply write php artisanwithin your command prompt it'll show you the list of commands over there have a look

如果您只是php artisan在命令提示符中写入,它会向您显示那边的命令列表,看看

enter image description here

在此处输入图片说明

回答by Taytus

In laravel 5.2 use php artisan make:console NameOfCommand

在 Laravel 5.2 中使用 php artisan make:console NameOfCommand