2

I am using Magento 2.3.4 now. I want try to Magento 2.4.5. But I don't upgrade Magento. when run command in cpanel terminal, show error like this.

$ composer require magento/product-community-edition 2.4.5 --no-update --no-plugins
./composer.json has been updated
$ composer update
The "magento/magento-composer-installer" plugin was skipped because it requires a Plugin API version ("^1.0") that does not match your Composerinstallation ("2.2.0"). You may need to run composer update with the "--no-plugins" option.
The "magento/inventory-composer-installer" plugin was skipped because it requires a Plugin API version ("^1.1") that does not match your Composer installation ("2.2.0"). You may need to run composer update with the "--no-plugins" option.
The "dealerdirect/phpcodesniffer-composer-installer" plugin was skipped because it requires a Plugin API version ("^1.0") that does not match your Composer installation ("2.2.0"). You may need to run composer update with the "--no-plugins" option.
Loading composer repositories with package information
Info from https://repo.packagist.org: #StandWithUkraine
Updating dependencies
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Root composer.json requires php ~7.3.0||~7.4.0 but your php version (7.2.34) does not satisfy that requirement.
  Problem 2
    - Root composer.json requires magento/product-community-edition 2.4.5 -> satisfiable by magento/product-community-edition[2.4.5].
    - magento/product-community-edition 2.4.5 requires php ~7.4.0||~8.1.0 -> your php version (7.2.34) does not satisfy that requirement.
  Problem 3
    - Root composer.json requires dealerdirect/phpcodesniffer-composer-installer ^0.5.0 -> satisfiable by dealerdirect/phpcodesniffer-composer-installer[v0.5.0].
    - dealerdirect/phpcodesniffer-composer-installer v0.5.0 requires composer-plugin-api ^1.0 -> found composer-plugin-api[2.2.0] but it does not match the constraint.

Use the option --with-all-dependencies (-W) to allow upgrades, downgrades and removals for packages currently locked to specific versions.

I think must upgrade composer and from php 7.2 to 7.4. Is right? if it's right, how to upgrade composer?

3 Answers 3

1
  1. You are using composer version 2.2.0, it is compatible with Magento 2.4.5.
  2. As you are using Magento 2.3.4, you can use PHP 7.3 or 8.1 to upgrade to Magento 2.4.5.
    As you are using PHP 7.2, you have to upgrade PHP to 7.3 or 8.1 to upgrade Magento to 2.4.5.
    After upgrading to Magento 2.4.5, it requires PHP 8.1.
  3. Magento released version 2.4.5-p1, you should upgrade Magento to that version instead of 2.4.5 to keep your site safe.

You can try one of the following solutions to upgrade your Magento site to 2.4.5-p1 (if solution 1 does not work for you, try solution 2):

Solution 1:

  1. Switch to PHP version 8.1.
  2. Update require-dev section in your composer.json file same as the Magento codebase: https://github.com/magento/magento2/blob/2.4.5-p1/composer.json#L108
  3. Run the following commands:
rm -rf vendor
composer remove magento/product-community-edition --no-update
composer require magento/composer-root-update-plugin ~2.0 --no-update
composer require-commerce magento/product-community-edition 2.4.5-p1 --no-update
composer update
bin/magento setup:upgrade
bin/magento setup:di:compile
bin/magento setup:static-content:deploy -f

Solution 2:

  1. Switch PHP to version 7.3.
  2. Run the following commands:
composer require magento/composer-root-update-plugin ~2.0 --no-update
composer update
rm -rf var/cache/* var/page_cache/* generated/*
bin/magento setup:upgrade
composer require-commerce magento/product-community-edition 2.4.5-p1 --no-update
composer update
  1. Change to PHP version 8.1
  2. Run the following commands:
rm -rf var/cache/* var/page_cache/* generated/*
bin/magento setup:upgrade
bin/magento setup:di:compile
bin/magento setup:static-content:deploy -f

If you still can't upgrade to Magento 2.4.5 (-p1), edit your question to add the content of your composer.json, I'll help you resolve it.

=== UPDATE ===
As you now want to upgrade to Magento 2.4.3, based on your composer.json, I've modified your composer.json to support upgrading to Magento 2.4.3-p3.

Update your composer.json with the following content:

{
    "name": "magento/project-community-edition",
    "description": "eCommerce Platform for Growth (Community Edition)",
    "type": "project",
    "license": [
        "OSL-3.0",
        "AFL-3.0"
    ],
    "config": {
        "preferred-install": "dist",
        "sort-packages": true,
        "allow-plugins": {
            "magento/*": true,
            "dealerdirect/phpcodesniffer-composer-installer": true,
            "laminas/laminas-dependency-plugin": true
        }
    },
    "require": {
        "magento/composer-dependency-version-audit-plugin": "~0.1",
        "magento/composer-root-update-plugin": "~2.0",
        "magento/data-migration-tool": "2.4.3",
        "magento/product-community-edition": "2.4.3-p3",
        "laminas/laminas-serializer": "^2.10",
        "addressfinder/module-magento2": "~2.0",
        "stripe/stripe-php": "^7.27"
    },
    "require-dev": {
        "allure-framework/allure-phpunit": "~1.4",
        "dealerdirect/phpcodesniffer-composer-installer": "^0.7.0",
        "friendsofphp/php-cs-fixer": "~2.18.1",
        "lusitanian/oauth": "~0.8.10",
        "magento/magento-coding-standard": "*",
        "magento/magento2-functional-testing-framework": "^3.0",
        "pdepend/pdepend": "~2.7.1",
        "phpcompatibility/php-compatibility": "^9.3",
        "phpmd/phpmd": "^2.8.0",
        "phpstan/phpstan": "^0.12.77",
        "phpunit/phpunit": "^9",
        "sebastian/phpcpd": "^6.0.3",
        "squizlabs/php_codesniffer": "~3.5.4",
        "symfony/finder": "^5.2"
    },
    "conflict": {
        "gene/bluefoot": "*"
    },
    "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/"
        },
        "psr-0": {
            "": [
                "app/code/",
                "generated/code/"
            ]
        },
        "files": [
            "app/etc/NonComposerComponentRegistration.php"
        ],
        "exclude-from-classmap": [
            "**/dev/**",
            "**/update/**",
            "**/Test/**"
        ]
    },
    "autoload-dev": {
        "psr-4": {
            "Magento\\Sniffs\\": "dev/tests/static/framework/Magento/Sniffs/",
            "Magento\\Tools\\": "dev/tools/Magento/Tools/",
            "Magento\\Tools\\Sanity\\": "dev/build/publication/sanity/Magento/Tools/Sanity/",
            "Magento\\TestFramework\\Inspection\\": "dev/tests/static/framework/Magento/TestFramework/Inspection/",
            "Magento\\TestFramework\\Utility\\": "dev/tests/static/framework/Magento/TestFramework/Utility/"
        }
    },
    "version": "2.4.3-p3",
    "minimum-stability": "stable",
    "repositories": {
        "0": {
            "type": "composer",
            "url": "https://repo.magento.com/"
        },
        "amasty": {
            "type": "composer",
            "url": "https://composer.amasty.com/community/"
        }
    },
    "extra": {
        "magento-force": "override"
    }
}

Then run composer update to upgrade to Magento 2.4.3-p3 and run the following commands to finish upgrade:

rm -rf var/cache/* var/page_cache/* generated/*
bin/magento setup:upgrade
bin/magento setup:di:compile
bin/magento setup:static-content:deploy -f

=== UPDATE ===
As you now want to upgrade to Magento 2.4.5-p1, based on your composer.json, I've modified your composer.json to support upgrading to Magento 2.4.5-p1.

Update your composer.json with the following content:

{
    "name": "magento/project-community-edition",
    "description": "eCommerce Platform for Growth (Community Edition)",
    "type": "project",
    "license": [
        "OSL-3.0",
        "AFL-3.0"
    ],
    "config": {
        "preferred-install": "dist",
        "sort-packages": true,
        "allow-plugins": {
            "magento/*": true,
            "dealerdirect/phpcodesniffer-composer-installer": true,
            "laminas/laminas-dependency-plugin": true
        }
    },
    "require": {
        "magento/composer-root-update-plugin": "~2.0",
        "magento/data-migration-tool": "2.4.5",
        "magento/product-community-edition": "2.4.5-p1",
        "addressfinder/module-magento2": "~2.0",
        "stripe/stripe-php": "^7.27"
    },
    "require-dev": {
        "allure-framework/allure-phpunit": "~1.5.0",
        "dealerdirect/phpcodesniffer-composer-installer": "^0.7.2",
        "friendsofphp/php-cs-fixer": "~3.4.0",
        "lusitanian/oauth": "~0.8.10",
        "magento/magento-coding-standard": "*",
        "magento/magento2-functional-testing-framework": "^3.7",
        "pdepend/pdepend": "~2.10.0",
        "phpmd/phpmd": "^2.12.0",
        "phpstan/phpstan": "^1.6.8",
        "phpunit/phpunit": "~9.5.20",
        "sebastian/phpcpd": "^6.0.3",
        "squizlabs/php_codesniffer": "~3.6.0",
        "symfony/finder": "^5.2"
    },
    "conflict": {
        "gene/bluefoot": "*"
    },
    "autoload": {
        "psr-4": {
            "Magento\\": "app/code/Magento/",
            "Magento\\Framework\\": "lib/internal/Magento/Framework/",
            "Magento\\Setup\\": "setup/src/Magento/Setup/"
        },
        "psr-0": {
            "": [
                "app/code/",
                "generated/code/"
            ]
        },
        "files": [
            "app/etc/NonComposerComponentRegistration.php"
        ],
        "exclude-from-classmap": [
            "**/dev/**",
            "**/update/**",
            "**/Test/**"
        ]
    },
    "autoload-dev": {
        "psr-4": {
            "Magento\\PhpStan\\": "dev/tests/static/framework/Magento/PhpStan/",
            "Magento\\Sniffs\\": "dev/tests/static/framework/Magento/Sniffs/",
            "Magento\\TestFramework\\Inspection\\": "dev/tests/static/framework/Magento/TestFramework/Inspection/",
            "Magento\\TestFramework\\Utility\\": "dev/tests/static/framework/Magento/TestFramework/Utility/",
            "Magento\\Tools\\": "dev/tools/Magento/Tools/",
            "Magento\\Tools\\Sanity\\": "dev/build/publication/sanity/Magento/Tools/Sanity/"
        }
    },
    "version": "2.4.5-p1",
    "minimum-stability": "stable",
    "repositories": {
        "0": {
            "type": "composer",
            "url": "https://repo.magento.com/"
        },
        "amasty": {
            "type": "composer",
            "url": "https://composer.amasty.com/community/"
        }
    },
    "extra": {
        "magento-force": "override"
    }
}

Then run composer update to upgrade to Magento 2.4.5-p1

And run the following commands to finish upgrade:

rm -rf var/cache/* var/page_cache/* generated/*
bin/magento setup:upgrade
bin/magento setup:di:compile
bin/magento setup:static-content:deploy -f
25
  • 1
    @BohdanV. Glad to help! If this answer helps you resolve your issue, please mark it as accepted (the check symbol at the top-left corner of my answer). That indicates your issue is solved and helps others with the same issue find out the verified answer easily.
    – Tu Van
    Nov 27, 2022 at 19:07
  • 1
    1. You have upgrade PHP to version 8.1 after run composer require-commerce magento/... and composer update. You can’t use PHP 7.4 for Magento 2.4.5. 2. Please enable or install PHP’s sodium extension. 3. Please edit your question to add the content of composer.json in your Magento root directory.
    – Tu Van
    Nov 28, 2022 at 0:18
  • 1
    3. When you have done your upgrade, either upgrade to 2.4.3 or 2.4.5, you have to upgrade the PHP version (PHP 7.4 for 2.4.3, PHP 8.1 for 2.4.5).
    – Tu Van
    Nov 28, 2022 at 1:10
  • 1
    @BohdanV. For the first point: it only shows suggestions for your composer package, in most cases, you can ignore them. For the second point: remove the app/code/AddressFinder/AddressFinder directory due to its duplicate with vendor/addressfinder/module-magento2
    – Tu Van
    Dec 2, 2022 at 6:41
  • 1
    Hi @BohdanV. I've added composer.json for your site to upgrade to Magento 2.4.5-p1.
    – Tu Van
    Dec 14, 2022 at 10:53
1
  1. Rewrite Composer.json

  2. Make inventory_stock1 structure in database and copy&paste from old database

    CREATE OR REPLACE VIEW inventory_stock_1 AS select distinct legacy_stock_status.product_id AS product_id, legacy_stock_status.website_id AS website_id, legacy_stock_status.stock_id AS stock_id, legacy_stock_status.qty AS quantity, legacy_stock_status.stock_status AS is_salable, product.sku AS sku from ( cataloginventory_stock_status legacy_stock_status join catalog_product_entity product on (( legacy_stock_status.product_id = product.entity_id )));

  3. Run command(if you installed AddressFinder , plz disable it.)

    composer update

    composer global require "squizlabs/php_codesniffer=*"

    composer global config bin-dir –absolute

    bin/magento module:enable AddressFinder_AddressFinder

    php bin/magento module:disable {Magento_Elasticsearch,Magento_InventoryElasticsearch,Magento_Elasticsearch6,Magento_Elasticsearch7}

    bin/magento setup:upgrade

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

    php bin/magento setup:upgrade

    php bin/magento setup:di:compile

    php bin/magento cache:clean

    php bin/magento cache:flush

    php bin/magento indexer:reindex

    php bin/magento setup:static-content:deploy -f

    bin/magento module:enable Magento_Elasticsearch6 Magento_Elasticsearch Magento_Elasticsearch7

    bin/magento module:disable Magento_TwoFactorAuth

  4. Select PHP 7.4 Sodium Extension enter image description here

  5. Install Elasticsearch package in server.

0

Please check these things :

Magento 2.4.5 requires PHP 8.1 Version
Composer 2

Please check other dependencies for the 2.4.5

And this is right to upgrading through composer.

5
  • Thank you Rana. Should I upgrade composer first? Could you explain more detail?
    – Bohdan V.
    Nov 27, 2022 at 18:46
  • You should upgrade the composer first and then the PHP version. This way seems to be the best
    – Rana Zain
    Nov 28, 2022 at 8:41
  • Thank you I updated composer and then php version. should I install php soldium extension?
    – Bohdan V.
    Nov 28, 2022 at 18:46
  • 1
    Please Install PHP 8.1 FPM with all extensions
    – Rana Zain
    Nov 29, 2022 at 8:00
  • If this help you please mark this an answer.
    – Rana Zain
    Dec 2, 2022 at 15:52

Your Answer

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

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