[php] How to force composer to reinstall a library?

I'm using the ZF2 skeleton app and it has a .gitignore that prevents external libraries from being commited to git. While debugging I like to go and change stuff here and there in the libraries' source to learn how things work. If these were version controlled it would be very easy to revert them back to their original state.

How can I force Composer to reinstall a particular framework so that I can get a fresh -unmodified- copy again?

PS: Please don't suggest removing the .gitignore file since it's there for a reason; it prevents my third party libraries from getting into my app's repository. I can always install them during an automated deployment.

This question is related to php zend-framework2 composer-php

The answer is


I didn't want to delete all the packages in vendor/ directory, so here is how I did it:

  1. rm -rf vendor/package-i-messed-up
  2. composer install again

What I did:

  1. Deleted that particular library's folder
  2. composer update --prefer-source vendor/library-name

It fetches the library again along with it's git repo


As user @aaracrr pointed out in a comment on another answer probably the best answer is to re-require the package with the same version constraint.

ie.

composer require vendor/package

or specifying a version constraint

composer require vendor/package:^1.0.0

For some reason no one suggested the obvious and the most straight forward way to force re-install:

> composer remove vendor-name/package-name && composer vendor-name/package-name

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

rm -rf vendor/

composer update -v

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


First execute composer clearcache

Then clear your vendors folder

rm -rf vendor/*

or better yet just remove the specific module which makes problems to avoid having to download all over again.


Examples related to php

I am receiving warning in Facebook Application using PHP SDK Pass PDO prepared statement to variables Parse error: syntax error, unexpected [ Preg_match backtrack error Removing "http://" from a string How do I hide the PHP explode delimiter from submitted form results? Problems with installation of Google App Engine SDK for php in OS X Laravel 4 with Sentry 2 add user to a group on Registration php & mysql query not echoing in html with tags? How do I show a message in the foreach loop?

Examples related to zend-framework2

How to install PHP intl extension in Ubuntu 14.04 Could not open input file: composer.phar How to force composer to reinstall a library? How to do left join in Doctrine? You must enable the openssl extension to download files via https How to access route, post, get etc. parameters in Zend Framework 2

Examples related to composer-php

Composer require runs out of memory. PHP Fatal error: Allowed memory size of 1610612736 bytes exhausted How to change PHP version used by composer PHP7 : install ext-dom issue PHP error: "The zip extension and unzip command are both missing, skipping." Composer: file_put_contents(./composer.json): failed to open stream: Permission denied require(vendor/autoload.php): failed to open stream How to install a specific version of package using Composer? Composer update memory limit Cannot create cache directory .. or directory is not writable. Proceeding without cache in Laravel To enable extensions, verify that they are enabled in those .ini files - Vagrant/Ubuntu/Magento 2.0.2