Question

I'm trying to upgrade my Magento installation to the version 2.3.5 using composer but I get the following error:

Uncaught Error: Undefined class constant 'PRE_COMMAND_RUN'

enter image description here

My composer.json is as follows

{
    "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
    },
    "require": {
        "bitexpert/magento2-force-customer-login": "^3.2",
        "magento/product-community-edition": "2.3.5",
        "mageplaza/magento-2-portuguese-language-pack": "dev-master",
        "mageplaza/module-smtp": "^1.2",
        "olegkoval/magento2-regenerate-url-rewrites": "^1.4"
    },
    "require-dev": {
        "friendsofphp/php-cs-fixer": "~2.13.0",
        "lusitanian/oauth": "~0.8.10",
        "magento/magento2-functional-testing-framework": "~2.3.13",
        "pdepend/pdepend": "2.5.2",
        "phpmd/phpmd": "@stable",
        "phpunit/phpunit": "~6.5.0",
        "sebastian/phpcpd": "~3.0.0",
        "squizlabs/php_codesniffer": "3.3.1",
        "allure-framework/allure-phpunit": "~1.2.0"
    },
    "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.3.1",
    "minimum-stability": "stable",
    "repositories": [
        {
            "type": "composer",
            "url": "https://repo.magento.com/"
        }
    ],
    "extra": {
        "magento-force": "override"
    }
}

Can anyone save me please ?

thanks for your time !

Was it helpful?

Solution

Try to run the following commands before doing upgrade.

composer clearcache
composer update --vvv --profile

Probably this file is missing or using an old version of a composer - vendor/composer/composer/src/Composer/Plugin/PluginEvents.php

Check above file has or not const PRE_COMMAND_RUN = 'pre-command-run';

May be required to upgrade the composer to the 1.9 or 1.10 to work with laminas libraries.

composer --version  
composer self-update

OTHER TIPS

Note that the following command:

composer self-update

Will update Composer to the latest version (2.0.7 at the time of this posting), which might bring up other issues if you are trying to install a specific Magento 2 version.

For example, for Magento 2.3.6, you might have issues using the latest Composer version [2.0.7]. I had this issue, and so I had to install the relevant Composer version for the specific install (1.10.13).

So you can update Composer to the specific version you require:

composer self-update 1.10.13

Or, install a specific version of Composer from the start. On Linux:

curl -sS https://getcomposer.org/installer -o composer-setup.php
sudo php composer-setup.php --install-dir=/usr/local/bin --filename=composer --version=1.10.13

Note: You would change the value of --version flag to the specific version you require.

I was updating to 2.3.3 to 2.3.5-p1 got this problem

Composer self-update was not working with my composer version, I use ubuntu(LEMP). Latest version of composer was installed - 1.6.3 I think.

We need this 1.10.17.

    sudo apt remove compsoer
    php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
    php -r "if (hash_file('sha384', 'composer-setup.php') === '756890a4488ce9024fc62c56153228907f1545c228516cbf63f885e036d37e9a59d27d63f46af1d4d07ee0f76181c7d3') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
    sudo php composer-setup.php --version=1.10.17 --install-dir=/usr/bin --filename=composer 

Check version:

composer --version
 
output: 1.10.17

To be sure remove all vendor and cache:

rm -rf vendor/*
composer clear-cache
composer update
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top