将子文件夹中各种集成的 Composer 供应商文件夹合并到一个根文件夹中
我在我的应用程序/项目和第 3 方集成(如 Mailchimp、Calendly ao)之间创建工具/桥梁,其中许多都有自己的包含文件的供应商文件夹。
典型的集成如下所示:
/tool1/index.php composer.json ...
/tool1/vendor/
/tool1/mycode/
/tool2/index.php composer.json ...
/tool2/vendor/
/tool2/mycode/
20 多个其他工具具有相同的结构,其中许多工具都有自己的供应商文件夹。大多数是从 GitHub 下载或安装的。
我正在尝试进行一些维护并将供应商文件夹集中到项目的根目录中,而不是从每个工具调用供应商文件夹。这样做的原因是大多数使用相同的软件包,例如 PSR、Guzzle、 league、composer ao
它应该看起来像这样:
/vendor/*
/tool1/index.php composer.json ...
/tool1/mycode/
/tool2/index.php composer.json ...
/tool2/mycode/
我的问题是(由于缺乏关于该主题的知识)我不知道该做什么处理我的每个工具的自动加载文件。显然,每个供应商文件夹中都有一个 autoload.php,专门用于该工具(我认为)。
这是自找麻烦吗?我是否最好将每个工具(包括供应商文件)分开,或者将其确实移动到根文件夹并花一些时间整理我的结构是否是一个好习惯。如果是后者,请告知如何保持正常工作。
I create tools/bridges between my app/project and 3rd party integrations (like Mailchimp, Calendly a.o.) many of which have their own vendor folder with files.
A typical integration looks like this:
/tool1/index.php composer.json ...
/tool1/vendor/
/tool1/mycode/
/tool2/index.php composer.json ...
/tool2/vendor/
/tool2/mycode/
Same structure for 20+ other tools, many of which have their own vendor folders. Most downloaded or installed from GitHub.
I'm trying to do some maintenance and centralize the vendor folder into the root of the project, instead of calling a vendor folder from each tool. The reason for this is that most use the same packages, such as PSR, Guzzle, league, composer a.o.
It should then look like this:
/vendor/*
/tool1/index.php composer.json ...
/tool1/mycode/
/tool2/index.php composer.json ...
/tool2/mycode/
My issue is (due to lack of knowledge on the subject) that I'm not sure what to do with the autoload files for each of my tools. Obviously, there's an autoload.php in each vendor folder, specifically for that 1 tool (I presume).
Is this asking for trouble and am I better of keeping each tool separated, including the vendor files, or is it good practise to indeed move it to the root folder and spend some time getting my structure in order. If the latter, please advise how to keep things working properly.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果这些确实是完全独立的工具,请将它们分开,并具有各自独立的依赖关系。
尝试合并多个 composer.json 文件将使您陷入依赖地狱,不同的工具需要不兼容的依赖项并且无法安装/更新。
尝试让一个供应商来处理多个项目将是一件愚蠢的事情,因为许多工具将使用相同依赖项的略有不同的版本。
将所有内容移动到同一个
composer.json
文件的唯一原因是,如果所有内容实际上都是一个项目,并且您需要保证一组版本约束以保持应用程序正常运行It these are really completely independent tools, keep them separated, with their own discrete dependencies.
Trying to merge multiple
composer.json
files will take you down into dependency-hell, with different tools requiring incompatible dependencies and not being able to install/update.And trying to have a single vendor for multiple projects will be a fool's errand, since many tools will use slightly different versions of the same dependencies.
The only reason to move everything to the same
composer.json
file is that if everything was actually one single project, and you need to guarantee a set of version constraints to keep the application working correctly