Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Should I add Laravel vendor directory to .gitignore or not?

I'm having my vendor directory in .gitignore file. Every time I run composer update , git can not track vendor directory updates and changes and therefor I can not backward these changes!!

My question is: Is it possible that application crash OR encounter errors after composer update so there is a need to git reset?

If it is possible, isn't it better to remove vendor directory from .gitignore ? maybe there are other solutions to this problem ? (if it is a problem at all !!)

like image 623
Ahmad Mobaraki Avatar asked Aug 28 '16 14:08

Ahmad Mobaraki


1 Answers

Composer provides the composer.lock file for this purpose.

Installing a new package, doing a composer update, etc. that causes package changes will write the exact versions of the installed packages to composer.lock. You should include this file in your repository's versioned files.

You can run composer install to automatically install the exact list of package versions from composer.lock. As it's going to be versioned, you can always roll it back to a working version and run composer install again.

Side note: composer dump-autoload shouldn't make any destructive changes in vendor.

like image 163
ceejayoz Avatar answered Oct 13 '22 00:10

ceejayoz