使用(独立)模块化项目安装多个Composer [英] Multiple Composer Installs with (Independent) Modular Projects

查看:541
本文介绍了使用(独立)模块化项目安装多个Composer的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试找到将作曲家用于模块化结构的最佳方法.

I am trying to find the best way to use composer for a modular structure.

假设我有这个框架树:

/cms
/site/addons

让我们说,开发人员可以使用加载项来添加其安装了composer.json的项目. 就像/site/addons/MyNewFeature/composer.json

Let's say that addons are available for developers to add their projects with their composer.json installs. Like /site/addons/MyNewFeature/composer.json

所以下一个问题是/vendor位置.每个插件都应该有一个/vendor目录,并且我应该在主框架中自动加载所有这些插件,我认为这样做的性能太高了,并且多次安装作曲家可能会安装许多相同的依赖项.而且我无法将它们全部安装在与/site/addons/vendor相同的/vendor目录中,因为作曲家将自动删除当前安装中未包括的所有项目,并使用其自己的锁定文件.

So the next question is the /vendor location. Should each addon have a /vendor directory and should I autoload them all within the main framework, which I think the performance of that would be too much and multiple composer installs would probably install a lot of the same dependencies. And I can't have them all install within the same /vendor directory like /site/addons/vendor because composer will automatically remove all projects not included in the current install and use its own lock file.

如何为基于模块化项目的系统安装多个作曲家?虽然每个项目都需要自己的作曲家供应商,但是为了提高性能,最好只包含1个供应商安装.我还没有找到解决方案,想知道你们中的任何一个是否有想法或将我引向正确的方向.

How could you do multiple composer installs for modular project based system; while each project requires its own composer vendor, but for performance it would be best to include only 1 vendor install. I have yet to find a solution to this and wondering if any of you guys have an idea or lead me into the right direction.

这几乎就像您需要一个主要的composer.json安装,该安装会自动转到每个插件并也安装它们...

This is almost like you need a main composer.json install that automatically goes to each one of the addons and installs them as well...

另一种解决方案是仅对所有插件(安装/更新)使用composer,这给了我更少的控制权,并且所有内容都位于/vendor目录中,因此带来了问题.

The other solution is just use composer for all the addon (installs/updates) which gives me less control and poses issues with everything being located in the /vendor directory.

推荐答案

经过一些研究和测试,我遇到了这个概念.

After some research and testing, I've come across this concept.

这允许框架按照设计方式手动安装/更新插件,并使用repositories通配符路径在主composer.json文件中安装/更新插件.

This allows the framework to install/update addons manually the way it was designed, and within the main composer.json file using repositories wildcard path.

"repositories": [
        {
            "type": "path",
            "url": "../site/addons/*",
            "options": {
                "symlink": false
            }
        }
    ]

现在,它将检查所有addon目录中的composer.json文件,并将其所有依赖项安装到一个通用的/vendor目录中,就像我最初想要的那样.

Now it will check all the addon directories for composer.json files and install all of their dependencies into a universal /vendor directory like I originally wanted.

我不确定这样做可能会导致以后出现的问题,但是到目前为止,这已经提供了我想要的控制权.

I am not sure the issues that may arise later by doing this, but so far this gives the control I want.

该框架只需要确保主json中的require具有已启用的所有插件即可.

The framework would just need to make sure the require in the main json has all the addons that are enabled.

https://getcomposer.org/doc/05-repositories.md#path

这篇关于使用(独立)模块化项目安装多个Composer的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆