我想知道如何在创建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
错误。
我该如何解决?
终于,我自己找到了灵魂。我不得不把它添加到我的包裹服务提供商注册功能中:
$this->app->register(CollectiveHtmlHtmlServiceProvider::class);
$loader = IlluminateFoundationAliasLoader::getInstance();
$loader->alias('Form', 'CollectiveHtmlFormFacade');
并在我正在开发包并安装的laravel安装中添加"laravelcollective.html":"5.2.*"。现在可以工作了。