“在”命令“命名空间中没有定义命令。”运行命令后:make in Laravel

问题描述:

就像在标题中一样。我试图从工匠“在”命令“命名空间中没有定义命令。”运行命令后:make in Laravel

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提示它会告诉你命令的列表那边有一个look

+5

谢谢你,我不应该相信的一切,我在教程看到 –

In la拉威尔5.2使用PHP的工匠制作:控制台NameOfCommand

由于文件说,(现在的版本是5.2,在这一刻):

一旦你的命令结束时,你需要工匠所以 它会进行注册可供使用。这是在 app/Console/Kernel.php文件中完成的。

在Kernel.php

文件,你必须添加: protected $commands = [ Commands\NameOfCommand::class ];

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

+1

感谢老兄此 –