Laravel 5.5软件包命令不会注册

时间:2017-08-31 14:14:26

标签: laravel package artisan laravel-5.5

我有一个Laravel 5.5的包,在CommandsServiceProvider boot()方法中,我有:

if($this->app->runningInConsole()){
    $this->commands([
        MyCommandClass:class,
    ]);
}

然后,我的MyCommandClass看起来像:

<?php

namespace Testing\Commands;

use Illuminate\Console\Command;

class MyCommandClass extends Command
{
    protected $signature = "execute:test";

    protected $description = "Description of the command";

    public function __construct()
    {
        parent::__construct();
    }

    public function handle()
    { 
        $this->info('Command Executed');
    }
}

问题是Artisan在运行php artisan时没有列出命令,当我尝试用php artisan execute:test运行命令时,它告诉我命令没有定义。

我在这里缺少什么?我按照registering package commands in Laravel 5.5

的文档进行操作

1 个答案:

答案 0 :(得分:0)

似乎只有在通过Composer从Git Repo中提取包时,自动发现才有效。在开发包时,包中的composer文件似乎不会自动加载。