Composer未安装本地软件包依赖项 [英] Composer not installing local package dependencies

查看:132
本文介绍了Composer未安装本地软件包依赖项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的Laravel 5.4 composer.json文件中,我有以下文件会自动加载自定义程序包.请注意,该软件包尚未发布,而是在本地加载.

In my Laravel 5.4 composer.json file I have the following that autoloads my custom package. Note, that this package is not published and is being loaded locally.

"autoload": {
    "classmap": [
        "database/seeds",
        "database/factories"
    ],
    "psr-4": {
        "App\\": "app/",
        "Vendor\\Module\\": "packages/vendor/module/src"
    }
},

然后在我的包composer.json文件中,有以下内容

And then in my package composer.json file I have the following

{
    "name": "vendor/module",
    "description": "A custom package",
    "version": "1.0.0",
    "type": "project",
    "authors": [
    ],
    "minimum-stability": "dev",
    "require": {
      "laravelcollective/html": "^5.4.0"
    }
}

但是,当我从Laravel根目录运行 composer install 时,它从不获取我需要的laravelcollective/html软件包.

However, when I run composer install from the root Laravel directory, it never picks up the laravelcollective/html package that I am requiring.

是否可以加载未发布的本地软件包的依赖项?

Is there a way to load in dependencies on a local package that is not published?

推荐答案

我相信我找到了一个解决方案,尽管它可能不是它对我有用的本地软件包开发的最佳方法.

I believe I found a solution, all though it may not be the best method for local package development it is working for me.

在root composer.json文件中,我添加了以下内容,并从应用程序的 root 运行 composer更新,现在看来可以获取该软件包及其依赖项并将所有内容安装到根应用程序的主供应商目录中.

In the root composer.json file, I added the following and running a composer update from the root of the application seems to now pick up the package and it's dependencies and installs everything into the main vendor directory of the root application.

"repositories": [
    {
        "type": "path",
        "url": "packages/vendor/module"
    }
],
"require-dev": {
    "fzaninotto/faker": "~1.4",
    "mockery/mockery": "0.9.*",
    "phpunit/phpunit": "~5.7",
    "vendor/module": "1.0.*"
},
"autoload": {
    "classmap": [
        "database/seeds",
        "database/factories"
    ],
    "psr-4": {
        "App\\": "app/",
        "Vendor\\Module\\": "packages/vendor/module/src"
    }
},

此方法的好处是它仅为自定义程序包创建符号链接,因此您可以继续在程序包目录中编写更新,并且更改将生效,而无需提交到本地git存储库在 composer.json 的存储库字段中将类型设置为 vcs .

The good thing about this method is it creates a symbolic link only for the custom package, thus you can continue to write updates in the packages directory and the changes will take affect instead of having to commit to your local git repository if you set the type to vcs in the repositories field of the composer.json.

我还必须在 require-dev 字段中指定版本号,以便它通过版本约束,否则您将收到警告,指出该软件包没有在运行composer时满足最低版本要求.

I also had to specify in the require-dev field the version number so that it passes the version constraint, otherwise you would get a warning that the package does not meet the minimum version requirements when running composer.

这篇关于Composer未安装本地软件包依赖项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆