How to make the composer reinstall the library?

I am using a ZF2 skeleton application and it has a .gitignore which prohibits the use of external libraries in git. During debugging, I would like to go and change the material here and there in the library source to find out how everything works. If they were version controlled, it would be very easy to get them back to their original state.

How can I get Composer to reinstall a specific structure to get a new, unmodified copy again?

PS: Please do not suggest deleting the .gitignore file, as it is for any reason; it prevents my third-party libraries from getting into my application repository. I can always install them during automatic deployment.

+71
php zend-framework2 composer-php
Oct 26 '13 at 20:07 on
source share
6 answers

You can use the --prefer-source flag for the composer to check external packages with VCS information (if any). You can simply return to the original state. Also, if you issue the composer update command, the composer will detect any changes you make locally and ask if you want to discard them.

Your .gitignore file is associated with your root project (ZF2 skeleton) and it does not allow the dir provider (where your third-party libraries are) to go to your own VCS. The ignore file is not associated with your suppliers git repo.

+41
Oct 26 '13 at
source share

Just empty the suppliers folder

 rm -rf vendor/* 
+136
Aug 11 '15 at 4:08
source share

What I've done:

  • This library folder has been deleted.
  • composer update --prefer-source vendor/library-name

He gets the library again with her git repo

+17
Dec 13 '16 at 17:41
source share

I did not want to remove all packages in the vendor/ directory, so here is how I did it:

  • rm -rf vendor/package-i-messed-up
  • composer install again
+14
Dec 16 '17 at 0:23
source share

Reinstall the dependencies. Delete the vendor folder (manually) or with the rm command (if you are in the project folder, be sure) on Linux before:

 rm -rf vendor/ composer update -v 

https://www.dev-metal.com/composer-problems-try-full-reset/

+1
Jun 04 '19 at 1:16
source share

As @aaracrr pointed out in a comment on another answer, probably the best answer is to re-request the package with the same version restriction.

i.e.

 composer require vendor/package 

or specifying a version limit

 composer require vendor/package:^1.0.0 
0
May 17 '19 at 11:36
source share



All Articles