You can upgrade your Magento application from the command line if you installed the software by:
Downloading the metapackage using
code
composer create-project
Installing the compressed archive.
Do not use this method to upgrade if you cloned the Magento 2 GitHub repository.
The following instructions show you how to upgrade Magento using Composer.
Magento 2.4.2 introduced support for Composer 2.
If you are attempting to upgrade from Magento <2.4.1(below 2.4.1' for example 2.4.0, 2.3.9, …), you must first upgrade to a version of Magento that is compatible with Composer 2 (for example, 2.4.2) using Composer 1 before upgrading to Composer 2 for Magento >2.4.2 (above 2.4.2 version) upgrades.
Prerequisites to prepare environment before starting the upgrade process:
Check PHP and environment settings Verify that PHP and other environment settings are compatible with the system requirements.
Switch to maintenance mode To prevent access to your store while it's being upgraded, switch your store to maintenance mode:code
php bin/magento maintenance:enable
Install the Composer update plugin The magento/composer-root-update-plugin Composer plugin resolves changes that need to be made to the root project composer.json file before updating to a new Magento product requirement.The plugin partially automates the manual upgrade by identifying and helping you resolve dependency conflicts instead of requiring you to identify and fix them manually.code
composer require magento/composer-root-update-plugin=~1.0 --no-update
Update the dependencies:code
composer update
Begin Update of Magento 2.
Backup the composer.json file.code
cp composer.json composer.json.bak
Indicate the Magento community edition packages and the version (2.4.0) that you want to upgrade to.
Magento Open Source:code
composer require magento/product-community-edition=2.4.0 --no-update
To see the full list of available 2.4 versions:
Magento Open Source:code
composer show magento/product-community-edition 2.4.* --all | grep -m 1 versions
Example : Minor release:
Minor releases contain new features, quality fixes, and security fixes. Use Composer to specify a minor release. For example, to specify the Adobe Commerce 2.3.7 metapackage:code
composer require magento/product-community-edition=2.3.7 --no-update
Example : Security Patch
Security patches contain security fixes only. They are designed to make the upgrade process faster and easier.
Use Composer to specify a patch.
For example, to download the Magento Open Source 2.3.6-p1 metapackage:code
composer require magento/product-community-edition=2.3.7 --no-update
Apply updates.code
composer update
Clear the var/ and generated/ subdirectories:code
rm -rf var/cache/*
rm -rf var/page_cache/*
rm -rf generated/code/*
Then Update the Database and Schema:code
php bin/magento setup:upgrade
After, Setup Upgrade do di:compile this command is use for compile all necessary files and generate files .code
php bin/magento setup:di:compile
Then after do content deploy command for deploy contetnt to magentocode
php bin/magento setup:static-content:deploy
Disable maintenance mode:code
php bin/magento maintenance:disableShare this playbook
