Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does composer deal with shared dependencies by multiple packages within one project?

As the questions states, if Project A requires x,y & z packages which they all in turn require d1, d2, d3, d4 & d5 packages. Does Composer download d1, d2, d3, d4 & d5 three times for x,y and z packages?

It sounds logical but not practical specially if d1,d2,d3,d4 & d4 packages require in turn another set of shared dependencies.... it would be a lot of duplicated code within one project code base.

Thanks in advance

like image 972
zoro74 Avatar asked Dec 15 '22 12:12

zoro74


1 Answers

The short answer is no. Since loading a library multiple times is impossible in PHP, downloading dependencies independently per package makes no sense. Therefore Composer will resolve all dependencies for all your packages, and then install them at once without duplication.

like image 156
Seldaek Avatar answered Feb 19 '23 08:02

Seldaek