使用composer在不同的路径上安装git包

时间:2016-12-22 02:25:55

标签: php wordpress git composer-php

我尝试使用composer在自定义路径中使用git安装存储库,因为我使用了Bedrock for WordPress。

在我的composer.json我有这段代码:

// ...
repositories: [{
    "type": "package",
    "package": {
        "name": "juniorgarcia/acf-gme",
        "version": "1.0.2",
        "source": {
            "url": "https://github.com/juniorgarcia/acf-gme",
            "type": "git",
            "reference": "master"
        }
    }
}]
// ...
"extra": {
    "installer-paths": {
        "web/app/plugins/{$name}/": ["type:wordpress-plugin"]
    }
}

我的存储库的composer.json具有以下内容:

{
    "name": "juniorgarcia/acf-gme",
    "type": "wordpress-plugin",
    "description": "A extended version of ACF Google Maps plugin with some more functionality.",
    "require": {
        "composer/installers": "~1.0"
    },
    "extra": {
        "installer-name": "advanced-custom-fields-google-map-extended"
    }
}

我按照作曲家的指示将其安装在自定义路径上但不起作用。它安装在vendor上。我做错了什么?

1 个答案:

答案 0 :(得分:0)

在分析composer.lock后,我意识到我的自定义存储库是这样插入的:

// ...
{
    "name": "juniorgarcia/acf-gme",
    "version": "1.0.2",
    "source": {
        "type": "git",
        "url": "https://github.com/juniorgarcia/acf-gme",
        "reference": "master"
    },
    "type": "library" // Notice here! Type is set to "library"
} // ...

类型设置为library,因此我在"type": "wordpress-plugin"上添加了composer.json,如下所示:

{ // ...
  "type": "package",
  "package": {
    "name": "juniorgarcia/acf-gme",
    "version": "1.0.2",
    "type": "wordpress-plugin", // Here is where I changed.
    "source": {
      "url": "https://github.com/juniorgarcia/acf-gme",
      "type": "git",
      "reference": "master"
    }
  }
} // ...

这很有用。我还更改了installer-name添加此信息,如:

// ... on my composer.json
"extra": {
    "installer-name": "advanced-custom-fields-google-maps-extended" // This also worked
 }

即使有了这个工作,我也想知道为什么作曲家不会读取已经包含composer.jsontype等信息的我的包type个文件。我很感激如果有人能解释我的话。