【问题标题】:"There are no commands defined in the 'command' namespace." after running command:make in Laravel“‘command’命名空间中没有定义任何命令。”在 Laravel 中运行命令后:make
【发布时间】:2015-11-30 12:00:14
【问题描述】:

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

php artisan command:make NameOfCommand

但我看到的只是

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

知道这是什么吗?

【问题讨论】:

  • 按照@Narendrasingh 的回答建议使用php artisan make:command NameOfCommand 创建命令后,您必须按照@Alejandro 回答的建议在app/console/kernel 中注册您的命令,以便命令正常工作。

标签: php laravel laravel-artisan


【解决方案1】:

正如文档所说(目前的版本是 5.2):

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

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

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

【讨论】:

  • 就是这样。 (这里是 Laravel 8 用户)
  • 是的@AkshayKNair,我们也必须在内核中注册我们的命令。
【解决方案2】:

你放错了命令

php artisan make:command NameOfCommand

而不是

php artisan command:make NameOfCommand

如果你只是在命令提示符下写了php artisan,它会显示那里的命令列表看看

【讨论】:

  • 谢谢,我不应该相信我在教程中看到的一切
【解决方案3】:

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

【讨论】:

    猜你喜欢
    • 2018-06-03
    • 2015-09-24
    • 2016-11-03
    • 2014-11-28
    • 2017-09-12
    • 2022-10-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多