如何在composer.json中覆盖单个包的vendor-dir

时间:2013-10-22 20:00:06

标签: git composer-php typo3-flow

我正在通过作曲家捆绑一个Web应用程序。在我的配置部分中,定义了框架所需的供应商目录(TYPO3流程):

"config": {
    "vendor-dir": "Packages/Libraries",
    "bin-dir": "bin"
},

现在我有一个自定义包,它不是来自Packagist,而是来自Github。需要将此包检出到Packages / Application / Vendor.PackageName。所以我尝试使用target-dir:

"repositories": [{
    "type": "package",
    "package": {
        "version": "dev-master",
        "name": "vendor/package",
        "source": {
            "url": "https://github.com/mycompany/mypackagerepo.git",
            "type": "git",
            "reference": "master"
        },
        "target-dir": "Packages/Application/Vendor.Package",
    }
}],
"require": {
    "typo3/flow": "2.0.*",
    "vendor/package": "dev-master"
}

从Github克隆工作正常,但现在已将包检出

Packages/Libraries/vendor/package/Packages/Application/Vendor.Package

这意味着vendor-dir和target-dir被连接在一起。

如何完全覆盖单个包的vendor-dir?谢谢你的帮助。

1 个答案:

答案 0 :(得分:5)

您需要使用Composer Installers并将包类型更改为target-dir,而不是typo3-flow-package,因此您的包定义可以是:

"repositories": [{
    "type": "package",
    "package": {
        "version": "dev-master",
        "name": "vendor/package",
        "type": "typo3-flow-package",  
        "source": {
            "url": "https://github.com/mycompany/mypackagerepo.git",
            "type": "git",
            "reference": "master"
        },
        "require": {
            "composer/installers": "~1.0"
        }
    }
]}

默认情况下,您的软件包将安装在Packages/Application/package下,但如果您想在软件包文件夹前加上供应商名称,并将其置于Packages/Application/vendor.package下,请添加:

"extra": {
    "installer-paths": {
        "Packages/Application/{$vendor}.{$name}/": ["type:typo3-flow-package"]
    }
}