Ahmad Mobaraki Ahmad Mobaraki - 1 year ago 128
Git Question

laravel vendor directory in .gitignore or not?

I'm having my vendor directory in

Every time I run
composer update
, git can not track
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
maybe there are other solutions to this problem ? (if it is a problem at all !!)

Answer Source

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.