I create tools/bridges between my app/project and 3rd party integrations (like Mailchimp, Calendly a.o.) many of which have their own vendor folder with files.
A typical integration looks like this:
/tool1/index.php composer.json ...
/tool1/vendor/
/tool1/mycode/
/tool2/index.php composer.json ...
/tool2/vendor/
/tool2/mycode/
Same structure for 20 other tools, many of which have their own vendor folders. Most downloaded or installed from GitHub.
I'm trying to do some maintenance and centralize the vendor folder into the root of the project, instead of calling a vendor folder from each tool. The reason for this is that most use the same packages, such as PSR, Guzzle, league, composer a.o.
It should then look like this:
/vendor/*
/tool1/index.php composer.json ...
/tool1/mycode/
/tool2/index.php composer.json ...
/tool2/mycode/
My issue is (due to lack of knowledge on the subject) that I'm not sure what to do with the autoload files for each of my tools. Obviously, there's an autoload.php in each vendor folder, specifically for that 1 tool (I presume).
Is this asking for trouble and am I better of keeping each tool separated, including the vendor files, or is it good practise to indeed move it to the root folder and spend some time getting my structure in order. If the latter, please advise how to keep things working properly.
CodePudding user response:
It these are really completely independent tools, keep them separated, with their own discrete dependencies.
Trying to merge multiple composer.json
files will take you down into dependency-hell, with different tools requiring incompatible dependencies and not being able to install/update.
And trying to have a single vendor for multiple projects will be a fool's errand, since many tools will use slightly different versions of the same dependencies.
The only reason to move everything to the same composer.json
file is that if everything was actually one single project, and you need to guarantee a set of version constraints to keep the application working correctly