46

I can't seem to be able to update my magento2 ce using composer. I doesn't find any updates, the only one it found was 'fabpot'.

I thought this was the whole point of a composer setup, so why would I want to use the backend as explained in the documentation: http://devdocs.magento.com/guides/v2.0/comp-mgr/upgrader/upgrade-start.html

Or am I missing something?

Thanks in advance for any help.


EDIT:

I followed the official documentation to install Magento2 via composer, as described here: http://devdocs.magento.com/guides/v2.0/install-gde/prereq/integrator_install.html#integrator-first-composer-ce

The problem is that the composer.json file that is pulled using the command: composer create-project --repository-url=https://repo.magento.com/ magento/project-community-edition <installation directory name> defined magento under the required section of the .json:

"require": {
    "magento/product-community-edition": "2.0.0",
    "composer/composer": "@alpha",
    "firegento/magesetup2": "dev-develop",
    "splendid/de_de": "^0.0.1"
},

As you can see, version 2.0.0 is specified.

For the update to work, I had to manually change that line in the .json file as follows:

 "magento/product-community-edition": "2.*",

Now running composer update updated all modules from version 100.0.2 to 100.0.3.

Please note that this still throws an error exception because of the following:

[ErrorException]                             
  Source /home/dev/git/mysite/vendor/magento/magento2-base/app/design/frontend/Magento does not exist

Now it seems quite a few essential are missing, for example the bin/magento file.

Anyone got any ideas how it is done correctly so it actually works?

2
  • If you installed 2.0 via packagist, there is an issue with 2.0.1. Please add repo.magento.com to your composer.json, and related auth info in the auth.json file.
    – Maddy
    Commented Jan 22, 2016 at 15:35
  • Upgrade magento 2 using composer required many technical knowledge about command line. If you are not tech-savvy, maybe upgrade via admin, magento commerce. Sometimes the composer method failed because of missing dependencies.
    – D. Joes
    Commented Sep 8, 2016 at 9:27

8 Answers 8

67

Edit the composer.json file on root folder and change the version of magento in line 5:

"version": "2.0.1",

and under "require"

"require": {
"magento/product-community-edition": "2.0.1",

Now run:

composer update

Then run:

php bin/magento setup:upgrade

And finally re-deploy the static files, which for me is this command:

php bin/magento setup:static-content:deploy de_DE en_US

That worked for me.

4
  • Thank you very much tecjam, this helped me alot! I was looking for a way to update for about one week. Greetings from Germany!
    – Java_Waldi
    Commented Jan 27, 2016 at 20:01
  • Great Answer. Given steps are very simple to follow. Commented Mar 17, 2017 at 5:09
  • 5
    There is no need to empty the vendor dir.
    – mniess
    Commented Dec 7, 2017 at 16:54
  • When update command is run,it show error :[Symfony\Component\Console\Exception\CommandNotFoundException] Command "composer" is not defined. Commented Dec 24, 2018 at 12:54
51

Updating/Upgrading to Magento 2.0.5 (via composer)

php bin/magento maintenance:enable
composer require magento/product-community-edition 2.0.5 --no-update
composer update
rm -rf var/di var/generation
php bin/magento cache:flush
php bin/magento setup:upgrade
php bin/magento setup:di:compile
php bin/magento indexer:reindex
php bin/magento maintenance:disable

After upgrade, check your Magento version with the following command:

php bin/magento --version

Upgrading to Magento 2.3.x

The above commands work fine while upgrading Magento to 2.2.x.

To upgrade to Magento 2.3.x, you need to follow some more steps.

Here's the step-by-step guide to upgrade Magento to 2.3.x:

Enable maintenance mode

php bin/magento maintenance:enable

Specify Magento packages

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

Specify additional packages

composer require --dev phpunit/phpunit:~6.2.0 friendsofphp/php-cs-fixer:~2.10.1 lusitanian/oauth:~0.8.10 pdepend/pdepend:2.5.2 sebastian/phpcpd:~3.0.0 squizlabs/php_codesniffer:3.2.2 --no-update

Remove unused packages

composer remove --dev sjparkinson/static-review fabpot/php-cs-fixer --no-update

Update autoload

Open composer.json and edit the "autoload": "psr-4" section to include "Zend\\Mvc\\Controller\\": "setup/src/Zend/Mvc/Controller/":

"autoload": {
    "psr-4": {
        "Magento\\Framework\\": "lib/internal/Magento/Framework/",
        "Magento\\Setup\\": "setup/src/Magento/Setup/",
        "Magento\\": "app/code/Magento/",
        "Zend\\Mvc\\Controller\\": "setup/src/Zend/Mvc/Controller/"
    },
    ...
}

Apply updates

composer update

Clean the Magento cache

php bin/magento cache:clean

Manually clear caches and generated content

Clear the var and generated subdirectories:

rm -rf <Magento install dir>/var/cache/*
rm -rf <Magento install dir>/var/page_cache/*
rm -rf <Magento install dir>/generated/code/*

If you use a cache storage other than the filesystem, such as Redis or Memcached, you must manually clear the cache there too.

Update the database schema and data

php bin/magento setup:upgrade

Disable maintenance mode

php bin/magento maintenance:disable

Finally, check your Magento version

php bin/magento --version

Read more: https://devdocs.magento.com/guides/v2.3/comp-mgr/cli/cli-upgrade.html

13
  • 2
    This worked fine :)
    – Arvind07
    Commented May 19, 2016 at 5:03
  • 1
    Don't you need to do a n98-magerun2 setup:static-content:deploy en_US ? Commented Jul 18, 2017 at 8:31
  • 1
    For me, the command composer require messed up everything. magento command is missing from bin as well.
    – Dyin
    Commented Aug 17, 2017 at 5:37
  • 1
    After following your steps it says "Magento supports 7.0.2, 7.0.4, and 7.0.6 or later. Please read devdocs.magento.com/guides/v1.0/install-gde/…" I have PHP 7.1.11 Commented Nov 17, 2017 at 10:45
  • 3
    I found this answer more useful than others. Already used it 4 times upgrading various minor M2 versions without any issue. Upvote this!!
    – Kalpesh
    Commented May 3, 2018 at 21:01
16

When upgrading through composer, you can choose the version of which you need to upgrade via a composer upgrade. For example:

composer require magento/product-community-edition 2.1.2 --no-update

The same command can be run if using Enterprise. For example:

composer require magento/product-enterprise-edition 2.0.6 --no-update

After running the relevant command, run

composer update

When composer has finished, upgrade your database by running the command:

php bin/magento setup:upgrade 

As ever, make a backup of your database and use a versioning tool such as git to protect yourself from the upgrade not going to plan.

1
  • Hello, I refer your comment and getting error. you can see below error. The requested package magento/product-enterprise-edition 2.0.6 exists as magento/product-enterprise-edition[2.0.2] but these are rejected by your constraint. can you please help to solve this issue. Commented Feb 21, 2017 at 6:45
7

To update Magento 2.0.x with sample data, I followed these steps (also works to update to 2.1 RC):

  1. Apply this commit manually (it's a bugfix for the sample data that is released with 2.1)
  2. Reset the sample data modules in Magento

    bin/magento sampledata:reset
    
  3. Update composer.json without immediately updating dependencies (this would result in a conflict because the old magento module versions are still locked). For 2.0.7:

    composer require --no-update magento/product-community-edition ~2.0.7
    

    or for the latest 2.1 release candidate

    composer require --no-update magento/product-community-edition 2.1.0-rc3
    
  4. [only if you update to >=2.1] Remove the sample data modules from composer.json:

    "magento/module-bundle-sample-data": "100.0.*",
    "magento/module-theme-sample-data": "100.0.*",
    "magento/module-widget-sample-data": "100.0.*",
    "magento/module-catalog-sample-data": "100.0.*",
    "magento/module-customer-sample-data": "100.0.*",
    "magento/module-cms-sample-data": "100.0.*",
    "magento/module-catalog-rule-sample-data": "100.0.*",
    "magento/module-sales-rule-sample-data": "100.0.*",
    "magento/module-review-sample-data": "100.0.*",
    "magento/module-tax-sample-data": "100.0.*",
    "magento/module-sales-sample-data": "100.0.*",
    "magento/module-grouped-product-sample-data": "100.0.*",
    "magento/module-downloadable-sample-data": "100.0.*",
    "magento/module-msrp-sample-data": "100.0.*",
    "magento/module-configurable-sample-data": "100.0.*",
    "magento/module-product-links-sample-data": "100.0.*",
    "magento/module-wishlist-sample-data": "100.0.*",
    "magento/module-swatches-sample-data": "100.0.*",
    "magento/sample-data-media": "100.0.*",
    "magento/module-offline-shipping-sample-data": "100.0.*",
    
  5. Run the actual composer update:

    composer update
    
  6. [only if you update to >=2.1] Reinstall sample data (you might need to apply the patch from (2) again):

    bin/magento sampledata:deploy
    
2
1

Step By Step run following command

composer require magento/product-community-edition 2.1.6 --no-update
composer update
rm -rf var/di var/generation
php bin/magento cache:flush
php bin/magento setup:upgrade
php bin/magento setup:di:compile(Optional)
php bin/magento indexer:reindex
chmod -R 777 var
php bin/magento setup:static-content:deploy

After upgrade, check your Magento version with the following command:

php bin/magento --version
0

Maybe you are missing something. First, connect your store with SSH. Now go to the root directory of your store.

Run all the commands one by one:

composer require magento/product-community-edition 2.1.3 --no-update

composer update

rm -rf var/di/* var/generation/* var/cache/* var/log/* var/page_cache/*

php bin/magento cache:clean

php bin/magento cache:flush

php bin/magento setup:upgrade

php bin/magento setup:di:compile

php bin/magento indexer:reindex
1
  • I already answered my own question, thanks. As you can see it was an issue with the first release of magento 2.0 - the documentation and issues have since been fixed.. An top of that I would never do a composer update directly on the server, never mind on the live shop.
    – tecjam
    Commented Jun 22, 2017 at 9:22
0

One can upgrade magento 2 using the two basic methods, one is from admin panel and other is using composer.

0
0

I've been using magento2 for a few months but I'm having trouble understanding how to update. Could anyone help me understand what this error means and how to fix it? BUT Upgrade should not install all updates automatically?

php bin/magento maintenance:enable

composer require magento/product-community-edition 2.4.6 --no-update

composer update --ignore-platform-reqs

*Loading composer repositories with package information Info from https://repo.packagist.org: #StandWithUkraine In Laminas\DependencyPlugin\DependencyRewriterV2:nPrePoolCreate Updating dependencies Your requirements could not be resolved to an installable set of packages. Problem 1

  • Root composer.json requires magento/product-community-edition 2.4.6 -> satisfiable by magento/product-community-edition[2.4.6].
  • magento/product-community-edition 2.4.6 requires colinmollenhour/credis ^1.13 -> found colinmollenhour/credis[v1.13.0, v1.13.1, v1.14.0] but it conflicts with your root composer.json require (1.12.1).*

Thanks Alessandro

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.