I have been thrusted into the "wonderful" world of Composer because PHP libraries are starting to not offer an easy way to download and install the source code manually.
We have a very big system with decades worth of code so some inevitable things are slated to occur such as:
- Preparing the server for a major PHP version upgrade
- We'll need libraries in place for both PHP versions during the migration
- Using new library version for current project and not breaking 30 previous projects which rely on old library version
- Upgrade 30 previous projects to use new library version
I am going to pick on Google/Cloud since it has several dependencies such as guzzlehttp.
If I do:
cd /libraries/composer/google/cloud/0.179.0
composer require google/cloud:0.179.0
cd /libraries/composer/different_vendor/package/version
composer require different_vendor/package:version
# pretend this different vendor requires a version of guzzlehttp which is incompatible with google/cloud
cd /libraries/composer/guzzlehttp/guzzle/7.4.2
composer require guzzlehttp/guzzle:7.4.2
Then would I have an issue writing code such as this?
<?php
require_once( '/libraries/composer/google/cloud/0.179.0/vendor/autoload.php' );
require_once( '/libraries/composer/different_vendor/package/version/vendor/autoload.php' );
require_once( '/libraries/composer/guzzlehttp/guzzle/7.4.2/vendor/autoload.php' );
If I have a need for google/cloud in one micro-app and guzzle in another then do I need to import google/cloud into the app that just needs guzzle?
I'm just trying to wrap my head around the benefits of Composer because all of the blogs mindlessly say "jUsT uSe ComPOsEr". I can see how composer is useful for one-off set-it-and-forget-it webapps which is presumably running on a dedicated server but that is far from our ecosystem; a website which serves public pages and various micro-apps requested by departments from a single domain.
I can definitely see why the code below would be a problem but I don't envision such a need ever occurring:
<?php
require_once( '/libraries/composer/google/cloud/0.178.0/vendor/autoload.php' );
require_once( '/libraries/composer/google/cloud/0.179.0/vendor/autoload.php' );