Laravel 5.5软件包命令赢得';t寄存器
我有一个针对Laravel 5.5的软件包,在Laravel 5.5软件包命令赢得';t寄存器,laravel,package,laravel-artisan,laravel-5.5,Laravel,Package,Laravel Artisan,Laravel 5.5,我有一个针对Laravel 5.5的软件包,在命令服务提供程序boot()方法中,我有: if($this->app->runningInConsole()){ $this->commands([ MyCommandClass:class, ]); } 然后,我的MyCommandClass看起来像: <?php namespace Testing\Commands; use Illuminate\Console\Command;
命令服务提供程序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');
}
}
似乎只有通过Composer从Git Repo中提取包时,自动发现才会起作用。在开发包时,包中的composer文件似乎不会自动加载。MyCommand类必须与类名相同。是的,在我的情况下,这只是一个输入错误。我更新了问题,谢谢你指出@Troyer,你已经在5.5中创建了包命令了吗?除了Laravel提供的文档外,我找不到任何其他文档,因为它太新了。似乎我在这里遗漏了什么…当我将MyCommand类移动到App/Console/Commands文件夹并手动将其添加到内核时,它工作正常,只是尝试通过包加载似乎不起作用。您是否在config/App.php
文件中添加了CommandServiceProvider
?