dongtuoao7987 2015-11-04 05:29
浏览 13
已采纳

在laravel 5中没有注册命令?

I am trying to build a new custom command in Laravel 5 like so:

php artisan make:console Tenant --command=tenant:do

And it created the class in App\Console\Commands like so:

<?php

namespace App\Console\Commands;

use Illuminate\Console\Command;

class Tenant extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'tenant:do';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'Run commands for all tenants.';

    /**
     * Create a new command instance.
     *
     * @return void
     */
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * Execute the console command.
     *
     * @return mixed
     */
    public function handle()
    {
        echo 'Hello World!';
    }
}

But now when I try to run this command with php artisan tenant:do, it return with an error saying:

[InvalidArgumentException] There are no commands defined in the "tenant" namespace.

I am not sure what I am doing wrong?

  • 写回答

1条回答 默认 最新

  • dsgk0386 2015-11-04 05:33
    关注

    Did you add your command to app/Console/Kernel.php, as outlined in the docs here: http://laravel.com/docs/5.1/artisan#registering-commands

    protected $commands = [
        'App\Console\Commands\Tenant'
    ];
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料