我有一个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
的文档进行操作答案 0 :(得分:0)
似乎只有在通过Composer从Git Repo中提取包时,自动发现才有效。在开发包时,包中的composer文件似乎不会自动加载。