Magento 2 – How to Install Module with Composer to Vendor Folder

composermagento2third-party-module

I have installed third party module with composer and we are managing code with Git.Since Module is installed with composer so it is going to Magento Vendor Folder.In git we are ignoring Vendor Folder.Hence this module is not tracked in Git while running git status.I am able to see modified in two files

"modified:   composer.json
modified:   composer.lock
"

My question is how I can install this module on server?Should I add and commit both modified files in git and run command composer update(but it will update whole magento) Or should I track that module in vendor folder in .gitignore file?

Please suggest me your thoughts.

Thanks.

Best Answer

Yes you would commit both the composer.json and composer.lock files.

As part of your deployment process to the live environment you would need to run composer install - this takes the information stored in the composer.lock file and recreates the very same versions you had installed locally.

Related Topic