Post by WizzSt » Sat May 30, 2020 6:38 pm

Hi.
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!

Newbie

Posts

Joined
Wed Apr 22, 2020 8:44 pm

Post by sw!tch » Sun May 31, 2020 2:42 am

If 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/"
    },

Backup and [ learn how to recover ] before you make any changes.


Active Member

Posts

Joined
Sat Apr 28, 2012 2:32 pm

Post by straightlight » Sun May 31, 2020 3:58 am

sw!tch wrote:
Sun May 31, 2020 2:42 am
If 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/"
    },
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.

The most generated errors being found on Opencart forum originates from contributed programming. The increased post counters are caused by redundancies of the same solutions that were already provided prior.


Regards,
Straightlight
Opencart.com Administrator / Quality Assurance Analyst / Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by sw!tch » Sun May 31, 2020 4:30 am

When 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.

Backup and [ learn how to recover ] before you make any changes.


Active Member

Posts

Joined
Sat Apr 28, 2012 2:32 pm

Post by straightlight » Sun May 31, 2020 5:04 am

sw!tch wrote:
Sun May 31, 2020 4:30 am
When 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.
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.

The most generated errors being found on Opencart forum originates from contributed programming. The increased post counters are caused by redundancies of the same solutions that were already provided prior.


Regards,
Straightlight
Opencart.com Administrator / Quality Assurance Analyst / Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by sw!tch » Sun May 31, 2020 5:18 am

Yeah the issue will only become apparent if you try to bring in a new composer package. You will see by default it doesn't take into account the "moved" storage directory. Very little documentation on OC about this, but we use composer a lot on client projects always have to adjust the vendor-dir path.

Backup and [ learn how to recover ] before you make any changes.


Active Member

Posts

Joined
Sat Apr 28, 2012 2:32 pm

Post by straightlight » Sun May 31, 2020 5:25 am

Ok, you may be on to something good here since Opencart does use a composer. Added to the FAQ with the storage folder step. Perhaps this could also be added in the install.txt file of the pre-release version to clarify this as well.

The most generated errors being found on Opencart forum originates from contributed programming. The increased post counters are caused by redundancies of the same solutions that were already provided prior.


Regards,
Straightlight
Opencart.com Administrator / Quality Assurance Analyst / Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by WizzSt » Sun May 31, 2020 6:07 pm

Hi.
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.

Newbie

Posts

Joined
Wed Apr 22, 2020 8:44 pm

Post by sw!tch » Mon Jun 01, 2020 2:01 am

WizzSt wrote:
Sun May 31, 2020 6:07 pm
Hi.
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.

Backup and [ learn how to recover ] before you make any changes.


Active Member

Posts

Joined
Sat Apr 28, 2012 2:32 pm

Post by WizzSt » Mon Jun 01, 2020 5:10 pm

sw!tch wrote:
Mon Jun 01, 2020 2:01 am
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.
Great, i will do that. Thank you for all the help!

Newbie

Posts

Joined
Wed Apr 22, 2020 8:44 pm

Post by paulfeakins » Mon Jun 01, 2020 8:07 pm

WizzSt wrote:
Mon Jun 01, 2020 5:10 pm
Great, i will do that. Thank you for all the help!
Please add [SOLVED] to the beginning of the post title if it is.

For quick, professional OpenCart support please email info@antropy.co.uk


User avatar
Guru Member

Posts

Joined
Mon Aug 22, 2011 11:01 pm
Location - Reigate, Surrey, United Kingdom
Who is online

Users browsing this forum: No registered users and 17 guests