Composer revert packages
-
13-06-2021 - |
Frage
I am building a new app in Symfony 2.1. I am using a lot of bundles pulled in using composer. A lot of these bundles have problems with this latest version of Symfony and I am having to go into the /vendor folder to identify the issues.
This means that I am changing the vendor files directly - purely for testing purposes. (When we have fixed a bundle we branch and submit appropriate pull request).
What I want to know is if there is some command like composer.phar revert
which would undo any changes made to the vendor folder (like a git checkout). At the moment if I run a composer update
or install
it does not do this.
Thanks
Lösung
composer install
, if you have kept your composer.lock file, will revert all your vendors to the previously installed state.
Andere Tipps
If you used composer update
your composer.lock
has changed to. So I make a little trick. Revert composer.lock
by git
and then run composer install
. It'll remove newest packages and download the previous.
Add discard-changes to your composer.json
file:
{
"config": {
"discard-changes": true
}
}
Make sure you are using the latest version of Composer.
cd /my/project/location/
rm -rf vendor/my_vendor_to_rollBack
composer install
As far as I can tell, none of the answers above work except in relation to versions. I you change an installed version, you can revert to a previous version.
If you just delete or change a file, though, the change will show up in composer status -v
, but there's no way to revert (even with "discard-changes":true
) except by removing and then re-requiring the package.