Home / Tutorials / How to Switch Between Composer Version 1 and 2
How to Switch Between Composer Version 1 and 2 cover

How to Switch Between Composer Version 1 and 2

4 mins


2 years ago



Many legacy projects require a dependency that still running on composer version 1 but what if your current composer version is 2? In this short post, you'll learn how to switch between version 1 and version 2 with few simple commands.

Switching Versions

To change to version one run the self-update command and pass in the --1 flag. This will change composer to version one and now you can install your dependencies.
composer self-update --1
Once you have installed your dependencies, now you can run the same command and pass in --2 as the flag and this will switch back to composer version 2.
composer self-update --2

Switching Specific Version

You can also change to a specific version which includes the minor version number as well and it's like below.
composer self-update 1.10.22
composer self-update 2.1.3

Update and Revert Version

To update the composer to the latest version, simply run the "self-update" command, and to revert back to the previous version do pass in the --rollback.
composer self-update
composer self-update --rollback

Preview Version

For anyone that's interested to use the preview version, the command below will allow you to get the pre-released version.
composer self-update --preview
notion avatar

Ahmad Aziz

Week-end developer currently experimenting with web, mobile, and all things programming.

Support Us

If you like our tutorial, support us by being our Patreon or buy us some coffee ☕️

Related Tutorials

Code Snippets

Collection of Laravel, AlpineJS, VueJS, Tailwind CSS, Flutter snippets and more. New snippets added every day.
View Snippets

Code Components

Collection of Tailwind CSS components for everyone to use. Browse all of the components that's right for your web projects
View Components

Welcome to PostSrc V3

PostSrc Dark Logo

You have to login to favorite this