Reputation: 8188
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 !!)
Upvotes: 14
Views: 26539
Reputation: 180176
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
.
Upvotes: 18
Reputation: 163978
vendor
directory is in .gitignore
by default. And this is a good idea, because composer
will install all packages it will find in composer.json
for you on any machine at any time. If you have trouble with new version of some package, just change it back in composer.json
and run composer update
again.
Of course you can remove vendor
directory from .gitignore
but this will slow down commits and will use much more disk and GitHub/BitBucket space etc.
Upvotes: 11