Skip to content

Magento 2 : setup:di:compile fails after upgrade

I have upgraded Magento from 2.4.5 to 2.4.7 and it went well.

Here are my system details

Composer version 2.7.6 

PHP version 8.2.12

Here are the steps I followed.

cp composer.json composer.json.bak && cp composer.lock
composer.lock.bak

composer require magento/composer-root-update-plugin=~2.0 –no-update

composer require-commerce magento/product-community-edition=2.4.7
–no-update

updated composer files section as mentioned below from https://github.com/magento/magento2/blob/2.4.7/composer.json

"psr-4": {
            "Magento\": "app/code/Magento/",
            "Magento\Framework\": "lib/internal/Magento/Framework/",
            "Magento\Setup\": "setup/src/Magento/Setup/"
        }


 "require-dev": {
             "allure-framework/allure-phpunit": "^2",
             "dealerdirect/phpcodesniffer-composer-installer": "^0.7 || ^1.0",
             "dg/bypass-finals": "^1.4",
             "friendsofphp/php-cs-fixer": "^3.22",
             "lusitanian/oauth": "^0.8",
             "magento/magento-coding-standard": "*",
             "magento/magento2-functional-testing-framework": "^4.7",
             "pdepend/pdepend": "^2.10",
             "phpmd/phpmd": "^2.12",
             "phpstan/phpstan": "^1.9",
             "phpunit/phpunit": "^9.5",
             "sebastian/phpcpd": "^6.0",
             "symfony/finder": "^6.4"
         },
    


"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/"
        }
    }, 

composer update

rm -rf var/cache/* var/page_cache/* generated/code/*

php bin/magento setup:upgrade
php bin/magento setup:di:compile

Here is the error

There is an error in /home/public_html/setup/src/Zend/Mvc/Controller/LazyControllerAbstractFactory.php at line: 78
Interface "ZendServiceManagerAbstractFactoryInterface" not found#0 /home/public_html/setup/src/Magento/Setup/Module/Di/Code/Reader/ClassesScanner.php(136): require_once()
#1 /home/public_html/setup/src/Magento/Setup/Module/Di/Code/Reader/ClassesScanner.php(117): MagentoSetupModuleDiCodeReaderClassesScanner->includeClass()
#2 /home/public_html/setup/src/Magento/Setup/Module/Di/Code/Reader/ClassesScanner.php(87): MagentoSetupModuleDiCodeReaderClassesScanner->extract()
#3 /home/public_html/setup/src/Magento/Setup/Module/Di/App/Task/Operation/ApplicationCodeGenerator.php(100): MagentoSetupModuleDiCodeReaderClassesScanner->getList()
#4 /home/public_html/setup/src/Magento/Setup/Module/Di/App/Task/Operation/ApplicationCodeGenerator.php(69): MagentoSetupModuleDiAppTaskOperationApplicationCodeGenerator->getFiles()
#5 /home/public_html/setup/src/Magento/Setup/Module/Di/App/Task/Manager.php(56): MagentoSetupModuleDiAppTaskOperationApplicationCodeGenerator->doOperation()
#6 /home/public_html/setup/src/Magento/Setup/Console/Command/DiCompileCommand.php(209): MagentoSetupModuleDiAppTaskManager->process()
#7 /home/public_html/vendor/symfony/console/Command/Command.php(326): MagentoSetupConsoleCommandDiCompileCommand->execute()
#8 /home/public_html/vendor/symfony/console/Application.php(1078): SymfonyComponentConsoleCommandCommand->run()
#9 /home/public_html/vendor/symfony/console/Application.php(324): SymfonyComponentConsoleApplication->doRunCommand()
#10 /home/public_html/vendor/magento/framework/Console/Cli.php(118): SymfonyComponentConsoleApplication->doRun()
#11 /home/public_html/vendor/symfony/console/Application.php(175): MagentoFrameworkConsoleCli->doRun()
#12 /home/public_html/bin/magento(23): SymfonyComponentConsoleApplication->run()
#13 {main}