Вопрос

This may be a pretty naive question, but I am trying to understand the difference in utility between Git's Subtree and Composer dependency management for PHP. I started using Git Subtrees after dumping Git Submodules. But now there is Composer (for PHP). As most of my projects are PHP based, I am thinking of dumping Subtrees in favor of Composer.

For example, I have multiple Wordpress sites. I would like to pull Wordpress itself and the plugins I want to use. I can achieve that with both Git Subtrees and Composer, right?

IF I don't have a use-case to commit/push code in a sub-folder upstream, but only wish to pull the latest/specific version into the sub-folder, do Subtree and Composer provide the same kind of utility?

In my use case, I feel that Composer trumps Git Subtree by being easier to use, easier to get another/newer version of a script in a sub-folder, without getting those pulled sub-folder files committed into Git repo.

Any thoughts on this understanding of mine? Is there a problem in this sort of strategy? Or both of them are totally different and don't have any similarities?

Это было полезно?

Решение

Lots of reasons favor Composer.

It actually manages dependencies of a whole project and vendor libraries themselves. So if you require a package it will get all required stuff or notify you about errors.

Managing versions is also trivial, as for every package you download you can specify version it should be updating to (so you can decide to only update minor releases of a package or go full-out with dev-master)

Composer provides some help with autoloading too. Making your project a little bit faster when run with -o

Having development only packages also allows you to manage production settings easier.

I find literally no reason for using submodules if vendor provides composer functionality.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top