【问题标题】:Install git package on different path with composer使用 composer 在不同的路径上安装 git 包
【发布时间】:2017-05-07 14:14:14
【问题描述】:

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

在我的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。我做错了什么?

【问题讨论】:

    标签: php wordpress git composer-php


    【解决方案1】:

    在分析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,所以我在composer.json 上添加了"type": "wordpress-plugin",如下所示:

    { // ...
      "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.json 文件,这些文件已经包含 typetype 等信息。如果有人可以解释我,我很感激。

    【讨论】:

      猜你喜欢
      • 2014-05-06
      • 2017-08-25
      • 2012-11-03
      • 1970-01-01
      • 2023-03-16
      • 2013-04-18
      • 2016-12-05
      • 2021-06-05
      • 2012-10-11
      相关资源
      最近更新 更多