在composer中指定项目根目录之外的依赖项(Specify dependency outside of project root in composer)

编程入门 行业动态 更新时间:2024-10-25 17:30:48
在composer中指定项目根目录之外的依赖项(Specify dependency outside of project root in composer)

我有一个项目目录。 这些都来自git repo。

其中一些项目是REST API,我希望将所有内容指定为项目依赖项,如下所示:

htdocs |- restApi1 |- restApi2 |- Vendor |-Guzzle |- restApi3

因此,项目2依赖于restApi1和restApi3。 我安装restApi2和build时,如果缺少restApi1或restApi3,我想做的是'git checkout'。 如果它已经签出,在composer install或update ,我希望它git pull并重建为自定义命令,就是这样。 由于我将这些设置作为项目,并且我可能正在对两个项目进行更改,如果我像这样作为依赖项:

htdocs |- restApi1 |- restApi2 |- Vendor |- Guzzle |- restApi1 |- restApi3 |- restApi3

我必须努力将我的更改添加到他们的回购中,工作到新的URL并且它会中断我的工作流程。 由于我通过localhost上的http命中项目,我可以从任何地方查看任何版本,并将所有内容视为一个大项目,其中所有代码库都出现一次。

我想知道在作曲家中是否有办法做到这一点,或者这是否是错误的方法。 我也愿意改变我的流量,如果这是一个更好的方式与上述冲突。 我考虑编写一个脚本来运行在htdocs ,它们可以通过搜索并提取所有内容,但我认为将其他项目指定为编辑器文件中的依赖项会显示有关内部项目如何相互使用的更多信息。

I have a directory of projects. Each of these is from a git repo.

Some of these projects are REST APIs, and I want everything specified as a project dependency, like this:

htdocs |- restApi1 |- restApi2 |- Vendor |-Guzzle |- restApi3

So project 2 has a dependency on restApi1 and restApi3. What I want to do is 'git checkout' if restApi1 or restApi3 is missing when I install restApi2 and build. If it is already checked out, upon composer install or update, I want it to git pull and rebuild to a custom command, that's it. Since I have these setup as projects and I might be working on a change across two projects, if I pull as a dependency in like this:

htdocs |- restApi1 |- restApi2 |- Vendor |- Guzzle |- restApi1 |- restApi3 |- restApi3

I have to do work to pull my changes into their repo, work to new URLs and it disrupts my workflow. Since I hit the projects through http on localhost, I can check out whatever version from wherever and treat everything as if it were one big project of sorts, where all my codebases appear once.

Im wondering if there is a way to do this in composer, or if this is the wrong way to go about it. Im also willing to switch my flow if theres a better way that conflicts the above. Ive considered writing a script to run on htdocs that rifles through and pulls everything, but I think specifying other projects as a dependency in the composer file reveals more info about how our internal prohjects use each other.

最满意答案

您可以将restApi1和restApi3添加到composer.json:

"require" : { ... "myproject/restApi1": "dev-master", "myproject/restApi3": "dev-master" }, "repositories": { "myproject/restApi1": { "url": "https://github.com/myproject/restApi1.git", "type":"git" }, "myproject/restApi3": { "url": "https://github.com/myproject/restApi3.git", "type":"git" }, }

然后,每当你想要新的更新时, composer update都会更新。

另一种选择是使用git子模块 。

You can add restApi1 and restApi3 to you composer.json:

"require" : { ... "myproject/restApi1": "dev-master", "myproject/restApi3": "dev-master" }, "repositories": { "myproject/restApi1": { "url": "https://github.com/myproject/restApi1.git", "type":"git" }, "myproject/restApi3": { "url": "https://github.com/myproject/restApi3.git", "type":"git" }, }

Then composer update each time yo want new updates.

The other option is to use git submodules.

更多推荐

项目,restApi,htdocs,电脑培训,计算机培训,IT培训"/> <meta name="description

本文发布于:2023-08-07 23:30:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1466440.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:根目录   项目   composer   root   project

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!