我一直在使用Magento Firegento自定义Composer安装程序,我遇到了一些我不太了解的奇怪的Composer行为。
考虑以下死简单composer.json
文件
{
"require": {
"magento-hackathon/magento-composer-installer": "*"
}
}
如果我使用此compser.phar install
文件运行composer.json
,我会得到以下内容。
$ 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
包
当我要求aoepeople/composer-installers
时,我不明白为什么作曲家安装magento-hackathon/magento-composer-installer
。
要明确:我了解magento-hackathon/magento-composer-installer
未安装的原因是这是一个位于different composer repository的软件包。我最初的错误是不在我的composer.json
文件中包含此存储库。
然而,对我来说,作曲家会安装一个与我要求的不同的包,这对我没有意义。当我search packagist there's no magento-hackathon/magento-composer-installer
extension时。
为什么packagist会安装不同的扩展程序?幕后发生了什么让magento-hackathon/magento-composer-installer
解析为aoepeople/composer-installers
?我将来如何/在作曲家来源中调试这种事情?
答案 0 :(得分:4)
Vinai在Magento和Composer here上发表了精彩的文章。
从那里引用
Composer将使用packagist.org查看获取库的位置。因为那里没有列出Magento模块,所以你必须将packages.firegento.org存储库添加到配置中,如下所示[...]
所以你需要存储库
"repositories":[
{
"type":"composer",
"url":"http://packages.firegento.com"
}
],
获取magento composer安装程序。
是的,作曲家提供替代品。在aoepeople/composer-installers的包装条目中,您会注意到替换部分:
由于packagist作曲家无法使用magento-hackathon/magento-composer-installer
,因此aoepeople/composer-installers
会为您提供。{/ p>
答案 1 :(得分:3)
好的,这是一个奇怪的行为:)我是 aoepeople / composer-installers 包的作者,其背后的想法是这个包提供了另一种选择(非常基本和简化的composer包类型magento-module
的实现 - 并添加了另一种类型magento-source
。我只希望安装程序将包放在正确的位置 - 保持简单。这就是' s为什么我决定提出一个替代方案。
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试图成为" smart"并返回一个包替换未注册的包对我来说是新的 - 说实话 - 非常令人不安。虽然这可能是预期的行为,但我认为这很容易被滥用。我开始喜欢Alan的想法,完全使用"packagist":"disabled"
绕过packagist。特别是在Magento模块的情况下,这似乎很容易发生,因为大多数Magento模块在pack.firegento.com注册时都不知道包装。
针对此特定情况的简单quickfix /解决方法可能是在packagist.org上注册 magento-hackathon / magento-composer-installer 。
答案 2 :(得分:1)
https://packagist.org/packages/aoepeople/composer-installers处的Packagist包中包含元数据,表示它取代了magento-hackathon / magento-composer-installer软件包。 Packagist然后会安装它,因为它是替换你要求的包。