Continue reading for OC 4.x here:
viewtopic.php?p=867361#p867361
This is something I have been looking into while evaluating opencart v4.0.2.3
It seems they use their own autoloader and grab files they wish to include via composer with a file:
This grabs a bunch of composer installed files and vendor tree libraries created in the initial install which are placed in your 'storage' directory outside of the web root. I'm not entirely sure how they install these files as they are essentially 'broken' in the initial creation of the storage folder on a vanilla install of opencart4. (if you try to run composer update in that directory, it fails in v4 due to a conflict between phpdocumentor and twig >v3. It will also try to upgrade
guzzlehttp/promises to a version that no longer includes the
functions_include.php file. See the 'issues' on the github repository
https://github.com/opencart/opencart/issues/13699 for more details.)
What I basically did (in version 4 of opencart) was replace the require line for phpdocumentor/phpdocumentor with phpdocumentor/shim: "^3"
Then I commented out almost the entire
system/vendor.php (everything that referenced the storage/vendor files) and replaced it with:
Code: Select all
require_once(DIR_STORAGE.'vendor/autoload.php');
This way, the composer autoloader will handle loading any and all files installed with composer. (this will include the new layout of
guzzlehttp/promises).
But, it should be noted, you only need to worry about this if you intend to change the core files which will likely break your ability to do a stock upgrade in the future. For adding extensions, it is possible and recommended to include a
system/ directory in the extension itself to load any composer files your code additions may need.
I was playing with this to see if I could use something like a dotenv loader for credentials such as AWS or the database -- unfortunately, the vendor.php is called 'after' config.php so I'm likely going to fall back to using the .htaccess for specifying the credentials as environment variables instead. I can then reference the environment variable instead of putting the credential(s) directly in the config files.