Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
701 views
in Technique[技术] by (71.8m points)

symfony - How does composer handle multiple versions of the same package?

This may (should) have been asked before somewhere but I can't seem to find an answer. If someone provides a link I can delete this post!:

Just trying to get my head around some of composer's (probably applies to other package managers too) functionality.

Basically I just want to know what composer does in the following scenarios:

1.

My main project has a dependency:

"guzzlehttp/guzzle": "5.0.*",

My external bundle has a dependency on

"guzzlehttp/guzzle": "5.0.*",

Does composer install guzzlehttp/guzzle one time because it knows it only needs it once?

2. Same scenario but in the future if someone updates the main project to use:

"guzzlehttp/guzzle": "6.0.*",

Will composer now install 2 versions of guzzle (5 and 6) (I presume this is what it should do), or will it take the highest version (i.e. 6)? Also if there are 2 versions will this cause any conflicts because namespaces might be the same?

Thanks

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

To question 1

Yes Composer can only install one version of each extension/package.

To question 2

Because of answer 1: Composer would consider your main project and the external package as incompatible.

In this case you could

  • stay with version 5 at your main project too.
  • ask the external package owner to upgrade to version 6 too if it's compatible to.
  • fork the external package and make it compatible to version 6 yourself

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...