如何在创建laravel包时注册依赖项

时间:2015-12-31 12:19:54

标签: php laravel composer-php packages

我想知道如何在创建laravel包时注册依赖项。

在我的包composer.json中,我有:

{
    "name": "facilinfo/gallery",
    "description": "Photo galleries management package for laravel",
    "type": "library",
    "license": "MIT",
    "keywords": ["laravel"],
    "authors": [
        {
            "name": "facilinfo",
            "email": "contact@facil-info.net"
        }
    ],
    "minimum-stability": "stable",
    "require": {
        "laravelcollective/html": "5.2.*",
        "intervention/image": "dev-master"
    },
    "autoload": {
        "psr-4": {
            "Facilinfo\\Gallery\\": "src/"
        }
    }
}

当我做的时候

$form = new Form();

我有Class not found错误。

我该如何解决?

1 个答案:

答案 0 :(得分:2)

最后,我自己找到了灵魂。我想把它添加到我的包服务提供者注册函数中:

 $this->app->register(\Collective\Html\HtmlServiceProvider::class);
    $loader = \Illuminate\Foundation\AliasLoader::getInstance();
    $loader->alias('Form', '\Collective\Html\FormFacade');

并添加" laravelcollective / html":" 5.2 *&#34。在laravel安装中,我开发我的包并安装。现在可以使用。