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 关于无人驾驶的航向角
  • ¥15 keil的map文件中Image component sizes各项意思
  • ¥30 BC260Y用MQTT向阿里云发布主题消息一直错误
  • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
  • ¥15 划分vlan后,链路不通了?
  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据
  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 Centos / PETGEM
  • ¥15 划分vlan后不通了
  • ¥20 用雷电模拟器安装百达屋apk一直闪退