Upgrade Magento from 2.1 to 2.2.1 with sample data using composer
-
16-12-2020 - |
Question
What steps do I need to follow to upgrade a demo installation with sample data from Magento 2.1 to the latest 2.2 version?
Instructions that work for Magento Commerce (Enterprise Edition) as well as Open Source (Community Edition) if possible.
Solution
Remove Magento 2.1 sample data modules:
bin/magento sampledata:remove
If you recieve an authentication error like this:
[Composer\Downloader\TransportException] The 'https://repo.magento.com/packages.json' URL required authentication. You must be using the interactive console to authenticate
you have to copy your stored credentials for repo.magento.com to
var/composer_home
because this is the composer home directory forbin/magento
commandscp ~/.composer/auth.json var/composer_home/
Specify new Magento version
For Open Source (CE):
composer require magento/product-community-edition 2.2.1 --no-update
For Commerce (EE):
composer require magento/product-enterprise-edition 2.2.1 --no-update
(Replace
2.2.1
with the current version if there's a newer one)Update dev requirement versions
This is necessary if you use the testing tools bundled with Magento. The current required versions can be found here: https://github.com/magento/magento2/blob/2.2/composer.json#L76-L82
composer require --dev --no-update \ phpunit/phpunit ~6.2.0 \ squizlabs/php_codesniffer 3.0.1 \ pdepend/pdepend 2.5.0 \ friendsofphp/php-cs-fixer ~2.1.1 \ lusitanian/oauth ~0.8.10 \ sebastian/phpcpd 2.0.4 composer remove --dev --no-update \ fabpot/php-cs-fixer \ sjparkinson/static-review
Trigger update
composer update
Review file permissions
You might need to set the correct file permissions again, for example make
bin/magento
executable:chmod +x bin/magento
And give appropiate write permissions to the new
generated
directory.More info: http://devdocs.magento.com/guides/v2.2/install-gde/install/file-sys-perms-over.html
Reinstall sample data
bin/magento sampledata:deploy bin/magento sampledata:reset
Upgrade database
bin/magento setup:upgrade
Compilations
If in production mode, also run the following compilation commands:
bin/magento setup:di:compile bin/magento setup:static-content:deploy