如何在多个项目中使用全局安装的Composer软件包? [英] How to use globally installed Composer packages in multiple projects?
问题描述
我的本地系统上的多个项目所需的Composer软件包列表越来越多.是否有配置设置和/或黑客手段让Composer在当前目录中查找软件包,如果找不到,则回退到全局目录.
I have a ever growing list of Composer packages that are required by multiple projects on my local system. Is there a configuration setting and/or hack to get Composer to look for a package in the current directory and fallback to the global directory if not found.
我知道有 [config] [use-include-path]
设置,但是我猜这不是很有效.
I know there is [config][use-include-path]
setting but I'm guessing that's not performant.
我知道Composer仅适用于单个项目依赖项管理,但在这种情况下,我会一遍又一遍地重新安装相同的软件包(相同的版本).
I know Composer is only meant for single-project dependency management but in this case I reinstalling the same packages (at the same version) over and over again.
推荐答案
是的,正如您所提到的,Composer仅用于单项目依赖项管理.全局更新软件包时,您(有时)会遇到不兼容的情况.一个项目需要更新时,另一个项目却变得不兼容,因为该项目的本地软件包需要较旧的版本.
Yes as you mentioned, Composer is meant only for single-project dependency management. You will (at some point) run into incompatibilities when you update a package globally. While one project needs the update, another project is getting incompatible because a local package of this project needs the older version.
您(以及与您合作的任何其他开发人员)是否偏favor并将其用作单项目依赖项.如果您需要一次又一次地更新相同的软件包,则可以编写脚本或类似的东西,如果需要的话,它可以一次更新整个项目.但是,请务必保持作曲家的整洁.
Do you (and any other developer working with you) a favor and use it as single-project dependency. If you need to update the same packages again and again write a script or something which updates the whole bunch of projects at once if you like. But hell keep your composer clean.
顺便说一句 dist 安装时,> Composer会缓存软件包.因此,只有第一个安装程序是从Internet下载的,其余的是从缓存安装的.
Btw Composer caches your packages when you install from dist
. So only the first install downloads from the Internet, the rest is installed from cache.
这篇关于如何在多个项目中使用全局安装的Composer软件包?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!