我正在通过 Composer 捆绑 Web 应用程序。在我的配置部分,定义了框架(TYPO3 Flow)所需的供应商目录:
"config": {
"vendor-dir": "Packages/Libraries",
"bin-dir": "bin"
},
现在我有一个自定义包,它不是来自 Packagist,而是来自 Github。这个包需要 checkout 到 Packages/Application/Vendor.PackageName。所以我尝试使用目标目录:
"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 克隆工作正常,但包现在 checkout 到
Packages/Libraries/vendor/package/Packages/Application/Vendor.Package
这意味着 vendor-dir 和 target-dir 是串联的。
如何为单个包完全覆盖 vendor-dir?感谢您的帮助。
最佳答案
您需要使用 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"]
}
}
关于git - 如何覆盖 composer.json 中单个包的供应商目录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19527180/