Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/variables/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Laravel 5.5软件包命令赢得';t寄存器_Laravel_Package_Laravel Artisan_Laravel 5.5 - Fatal编程技术网

Laravel 5.5软件包命令赢得';t寄存器

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;

我有一个针对Laravel 5.5的软件包,在
命令服务提供程序
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