How to upgrade Magento 2 using composer?

Many developers have a question in mind how to upgrade Magento without losing any module installed through composer

Just need to follow below few steps and it will upgrade Magento with ease

First, update your composer file with the version you need

For Community Magento 2

composer require magento/product-community-edition=2.3.6 --no-update

For Commerce Magento 2

composer require magento/product-enterprise-edition=2.3.6 --no-update

Note: EE edition will need auth.json set up with API credentials from Magento account

Now simply run below command and wait till it finishes the upgrade

composer update

After it finishes upgrade need clean up data using below commands

php bin/magento setup:upgrade
php bin/magento cache:clean
php bin/magento cache:flush
php bin/magento indexer:reindex

That’s it.

You are ready with your upgraded magento