在laravel 5中没有注册命令?

Roh*_*han 0 php laravel laravel-5

我正在尝试在Laravel 5中构建一个新的自定义命令,如下所示:

php artisan make:console Tenant --command=tenant:do
Run Code Online (Sandbox Code Playgroud)

它在App\Console\Commands中创建了类,如下所示:

<?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!';
    }
}
Run Code Online (Sandbox Code Playgroud)

但是现在当我尝试运行此命令时php artisan tenant:do,它返回错误说:

[InvalidArgumentException]"租户"命名空间中没有定义命令.

我不确定我做错了什么?

小智 10

您是否添加了命令app/Console/Kernel.php,如文档中所述:http://laravel.com/docs/5.1/artisan#registering-commands

protected $commands = [
    'App\Console\Commands\Tenant'
];
Run Code Online (Sandbox Code Playgroud)