Using Composer when multiple components are in the same vcs repo

余生长醉 提交于 2020-01-03 04:24:05

问题


I have a git repo that contains a few small and related libraries. Since the platform I am working with lacks proper dependency management, dealing with many git repos is a hassle, hence my team decided to put these into one git repo. I'm now working on having our software being installable via Composer. It is however not clear to me how to register each component in this git repo, as I'm not even sure it is possible to have more then one composer.json file per repo. Is this possible? And if so, how?


回答1:


"is it possible to have more then one composer.json file per repo."

No.

You can't register the components separately, they will be registered as one big dependency and you will have to import them all into other projects, rather than being able to pull them individually.

However you can register where each component lives in the directory structure so that the autoloader is able to load them correctly.

"autoload": {
    "psr-0": {
        "Intahwebz\\Component1": "src/Component1",
        "Intahwebz\\Component2": "src/Intahwebz/Component2",
        "Intahwebz": "src/"
    }
}

After including the Composer generated autoloader, creating a new class of type Intahwebz\Component1\TestClass will find it in the correct directory.



来源:https://stackoverflow.com/questions/16946482/using-composer-when-multiple-components-are-in-the-same-vcs-repo

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!