Vender folder in .gitignore
Hi there, I'm curious about the reason for including the vendor folder in .gitignore. For my setup, this means that I have to run composer install again on my server after already installing everything locally.
I assumed there might be a good reason for this practice, but I'd like to understand the purpose behind it and whether removing it from .gitignore
would cause any issues.
Thanks for any insights!
Hey!
Interestingly enough, we just had this exact question a couple of weeks ago:
Including the vendor
folder in your .gitignore
is standard practice in the PHP world, especially when you're using Composer. This is also valid for almost all other languages like JS with npm
, yarn
and the node_modules directory for exmaple.
Essentially, the vendor
folder can get hefty. Excluding it keeps your repository lightweight and speedy to clone.
Also, dependencies update frequently. Tracking these changes in version control can lead to unnecessary merge conflicts all of the time.
By running composer install
in each environment, you're making sure that everyone, from development to production, is on the same page, dependency-wise.
Running composer install
on your server—consider it a small price for maintaining a clean and consistent workflow. If it's a hassle, you might want to explore optimizing your deployment process, perhaps with CI/CD pipelines, to streamline this step.
In essence, while it might seem tempting to track vendor
, resisting the urge keeps your project clean, consistent, and in harmony with Composer's ecosystem.