【问题标题】:Why does Composer Install a Different Package?为什么 Composer 安装不同的包?
【发布时间】:2014-04-28 13:59:22
【问题描述】:

我一直在使用 Magento Firegento 自定义 Composer 安装程序,但遇到了我不理解的这种奇怪的 Composer 行为。

考虑以下简单的composer.json 文件

{
    "require": {
        "magento-hackathon/magento-composer-installer": "*"
    }
}

如果我用这个composer.json 文件运行compser.phar install,我会得到以下信息。

$ composer.phar install --no-dev 
Loading composer repositories with package information
Installing dependencies
  - Installing aoepeople/composer-installers (v0.0.1)
    Loading from cache

Writing lock file
Generating autoload files

根据我大部分外行的理解composer.phar,我说过

嗨,作曲家,请从 packagist.org 安装 magento-hackathon/magento-composer-installer

作曲家已经回复我了

先生,是的,先生!这是aoepeople/composer-installers

当我询问 magento-hackathon/magento-composer-installer 时,我不明白为什么 composer 安装了 aoepeople/composer-installers

明确一点:我理解未安装 magento-hackathon/magento-composer-installer 的原因是这是一个位于 different composer repository 中的软件包。我最初的错误是没有在我的composer.json 文件中包含这个存储库。

然而,composer 会安装与我要求的不同的软件包,这对我来说是没有意义的。当我search packagist there's no magento-hackathon/magento-composer-installer extension

为什么 packagist 安装不同的扩展程序?幕后发生了什么使magento-hackathon/magento-composer-installer 解析为aoepeople/composer-installers?我将来如何/在作曲家源代码中自己调试这种东西?

【问题讨论】:

    标签: php magento composer-php


    【解决方案1】:

    Vinai 发表了一篇关于 Magento 和 Composer here 的精彩文章。

    从那里引用

    Composer 将使用 packagist.org 查找获取库的位置。由于 Magento 模块未在此处列出,因此您必须将 packages.firegento.org 存储库添加到配置中,如下所示 [...]

    所以你需要仓库

       "repositories":[
         {
           "type":"composer",
           "url":"http://packages.firegento.com"
         }
       ],
    

    获取 magento 作曲家安装程序。

    是的,作曲家提供替代品。在aoepeople/composer-installers 的包装条目上,您会注意到替换部分:

    并且由于 magento-hackathon/magento-composer-installer 在 packagist 上不可用,因此作曲家将为您提供 aoepeople/composer-installers

    【讨论】:

      【解决方案2】:

      好的,这是一个奇怪的行为 :) 我是 aoepeople/composer-installers 包的作者,这背后的想法是这个包提供了一个替代方案(非常基本和简化的实现作曲家包类型magento-module - 并添加另一个类型magento-source。我只希望安装程序将包放在正确的位置 - 保持简单。这就是我决定提出替代包的原因。

      aoepeople/composer-installer 取代 magento-hackathon/magento-composer-installer 的原因是因为许多 Magento 模块已经带有 composer.json需要 magento-hackathon/magento-composer-installer。为了能够无缝地使用“假装”为黑客马拉松安装程序的更简单的安装程序。但是,除非您在项目的 composer.json 中主动要求 aoepeople/composer-installers,否则您应该继续使用原始安装程序,因为没有 Magento 模块的 composer.json(甚至我们的)直接引用 aoepeople/composer-installers.

      packagist 试图变得“聪明”并返回一个包来替换未注册的包的事实对我来说是新的 - 老实说 - 非常令人不安。虽然这可能是有意的行为,但我认为这很容易被滥用。我开始喜欢 Alan 使用 "packagist":"disabled" 完全绕过 packagegist 的想法。尤其是在 Magento 模块的情况下,这似乎很容易发生,因为大多数 Magento 模块在仅在 packages.firegento.com 上注册时对 packagegist 是未知的。

      针对这种特定情况的简单快速修复/解决方法可能是在 packagist.org 上注册 magento-hackathon/magento-composer-installer

      【讨论】:

        【解决方案3】:

        https://packagist.org/packages/aoepeople/composer-installers 的 Packagist 包有元数据,表明它取代了 magento-hackathon/magento-composer-installer 包。然后,Packagist 会安装它,因为它是替换您要求的软件包。

        这里的文档:https://getcomposer.org/doc/04-schema.md#replace

        【讨论】:

          猜你喜欢
          • 2018-07-01
          • 2018-07-05
          • 2016-06-30
          • 1970-01-01
          • 2020-07-05
          • 2017-03-13
          • 1970-01-01
          • 2020-08-20
          • 2015-05-30
          相关资源
          最近更新 更多