How to revert back composer update? How to revert back composer update? laravel laravel

How to revert back composer update?


How to revert an update? Easy: Restore the composer.lock file from your version control system that was used before you updated.

The composer.lock exactly records which software was installed. So it is paramount to commit this file into version control in order to be able to go back to a working version in case of update failure.

Running composer install will always install the software versions recorded in composer.lock, it will only act like update if this file is not present.


If you check the composer version specification documentation, the ~ operator gets the latest version that is backwards-compatible according the principles of semantic versioning. That means that ~1.8 is equivalent to >=1.8 <2.0.0 and likewise ~1.9 is the same as >=1.9 <2.0.0. In other words, ~1.8 will return the SAME THING as ~1.9 if the latest version is >=1.9. If you really want to use version 1.8, just do this:

"danielstjules/stringy": "1.8",

That will get EXACTLY version 1.8. Of course you'll need to run composer update afterwards.

I find the composer versioning syntax tricky to remember myself.