I am using Opencart Version 3.0.3.3 locally, and i would like to add an external library to opencart.
The library is google-api-php-client (https://github.com/googleapis/google-api-php-client). I folowed the instructions from README.md and tried to install the library with composer. I installed composer for windows (its a window machine with Apache2) and the installation was sucessfull.
As far as I understand it, the external libraries are located in '\system\storage\vendor' folder. So, composer created a few new folders in the vendor folder: google, firebase etc, and two new files in system\storage folder: composer.json and composer.lock. Still I can not access the new library from code.
I dont have experience with mvc php projects, as i usually work with .net projects, where you basically just add a dll in project reference, so any help would be appreciated.
I can also just download a release version of the google api library, but still i dont really know how to include it in the autoloader.
Thanks in advance!
(eg.
Code: Select all
"config": {
"vendor-dir": "./storage/vendor/"
},
Backup and learn how to recover before you make any changes!
The vendor-dir does not reflect anywhere else on the platform. The most important part is that the storage folder gets moved outside of the public_html folder, or similar environment names, and to assign the CHMOD permissions recursively to 0755. Then to edit both config files should suffice.sw!tch wrote: ↑Sun May 31, 2020 2:42 amIf I recall OC looks in the "system/storage/vendor" by default, but if you moved your storage folder as it instructs after install. I believe you need to then update your vendor-dir in composer.json.
(eg.
Code: Select all
"config": { "vendor-dir": "./storage/vendor/" },
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
This is most likely why the OP can't access the newly installed packages.
Backup and learn how to recover before you make any changes!
During each installs, I never had to do this with the storage folder before and the cache folder does seem to respond accordingly. However, you are making a good point when packaging with a composer.sw!tch wrote: ↑Sun May 31, 2020 4:30 amWhen you run composer require or composer update its going to use the vendor-dir path defined in your composer.json file to install those packages. If you have moved your storage folder as it requires on install, I believe you have to also update your composer.json so it references the updated storage folder path..
This is most likely why the OP can't access the newly installed packages.
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
Backup and learn how to recover before you make any changes!
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
Yes , you were right, i was looking in the wrong folder. After the installation of Opencart, after logging to admin area, I did get the popup for moving the storage folder, and it was moved outside the public_html folder. However, the old one was not deleted. That is why i was looking in the wrong one. The path to the storage folder in both config.php's is set to the one outside the project folder.
I ran the compiler in the outside storage folder and this time the new library can be accessed from code.
I still have one question. Now that the new libraries are installed on my local machine, how do I reflect those changes in production?
Can i just copy the vendor folder and the two new files in storage folder (composer.json and composer.lock) on the production macchine?
As I dont really have access to composer on production.
You can just zip the storage dir and then unzip it on your production env. Just make sure to keep the storage dir outside the public folder and also update your config.php with your production paths.WizzSt wrote: ↑Sun May 31, 2020 6:07 pmHi.
Yes , you were right, i was looking in the wrong folder. After the installation of Opencart, after logging to admin area, I did get the popup for moving the storage folder, and it was moved outside the public_html folder. However, the old one was not deleted. That is why i was looking in the wrong one. The path to the storage folder in both config.php's is set to the one outside the project folder.
I ran the compiler in the outside storage folder and this time the new library can be accessed from code.
I still have one question. Now that the new libraries are installed on my local machine, how do I reflect those changes in production?
Can i just copy the vendor folder and the two new files in storage folder (composer.json and composer.lock) on the production macchine?
As I dont really have access to composer on production.
Backup and learn how to recover before you make any changes!
Please add [SOLVED] to the beginning of the post title if it is.
UK OpenCart Hosting | OpenCart Audits | OpenCart Support - please email info@antropy.co.uk
Users browsing this forum: Bing [Bot] and 15 guests