Composer - 使用本地存储库 [英] Composer - using a local repository

查看:407
本文介绍了Composer - 使用本地存储库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是一个作曲家初学者,我试图使一个项目依赖于另一个项目,而这两个项目只存在于我的本地机器上。



我的库项目(ProjectA)中的composer.json是:

  {
name:project / util,
type:library
}

我在这个项目的基本文件夹中初始化了git。



我的composer.json在项目中取决于第一个(ProjectB):

  {
repositories:[
{
name:util,
type:git,
url :/ d / workspaces / util
}
],

require:{
project / util:*$ b $当我运行 composer install 时,






$ b 从ProjectB,我得到以下错误:

  [RuntimeException] 
无法克隆不读取程序包
fatal:repository''不存在

错误的仓库的url,但我不知道还有什么要写在那里。

解决方案

我认为你的语法错误。



因此,在你的项目B中,仓库的条目应该是:

 repositories:[
{
type:vcs,
url :/ d / workspaces / util
}
],

不需要在 / d / workspaces / util 中命名可用的库。 Composer将扫描该目录中的composer.json文件,并知道该目录中有哪些项目名称,并使用该目录中的项目,优先于packagist或其他存储库中列出的版本。


I am a Composer beginner and I am trying to make one project dependent of another one, while both project only exist on my local machine.

The composer.json in my library project (ProjectA) is:

{
    "name" : "project/util",
    "type" : "library"
}

I initialized git in the base folder of this project.

My composer.json in the project depending on the first one (ProjectB):

{
    "repositories": [
        {
            "name" : "util", 
            "type" : "git",
            "url" : "/d/workspaces/util"
        }   
    ],

    "require": {
        "project/util" : "*"
    },
}

When I run composer install from ProjectB, I get the following error:

[RuntimeException]
Failed to clone , could not read packages from it
fatal: repository '' does not exist

I asume something is wrong with the url of the repository, but I am not sure what else to write there.

解决方案

I think you've just got the syntax wrong. The type should just be VCS, and then composer figures out what type of VCS it is.

So in your project B, the entry for repositories should be:

"repositories": [
    {
        "type": "vcs",
        "url" : "/d/workspaces/util"
    }
],

You don't need to name what library is available in /d/workspaces/util. Composer will scan the composer.json file in that directory and know what project name is available there, and use the project from that directory in preference to a version listed on packagist or other repository.

这篇关于Composer - 使用本地存储库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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