Previous version Magento 2.4.5 and php 7.4
After upgrade php version 8.1 getting compile error < 1 sec 117.0 MiBsyntax error, unexpected token "<"#0 /var/www/html/magento/setup/src/Magento/Setup/Module/Di/Code/Reader/ClassesScanner.php(117): Magento\Setup\Module\Di\Code\Reader\ClassesScanner->includeClass() #1 /var/www/html/magento/setup/src/Magento/Setup/Module/Di/Code/Reader/ClassesScanner.php(87): Magento\Setup\Module\Di\Code\Reader\ClassesScanner->extract() #2 /var/www/html/magento/setup/src/Magento/Setup/Module/Di/App/Task/Operation/RepositoryGenerator.php(61): Magento\Setup\Module\Di\Code\Reader\ClassesScanner->getList() #3 /var/www/html/magento/setup/src/Magento/Setup/Module/Di/App/Task/Manager.php(56): Magento\Setup\Module\Di\App\Task\Operation\RepositoryGenerator->doOperation() #4 /var/www/html/magento/setup/src/Magento/Setup/Console/Command/DiCompileCommand.php(216): Magento\Setup\Module\Di\App\Task\Manager->process()
After debug the code in /var/www/html/magento/setup/src/Magento/Setup/Module/Di/Code/Reader/ClassesScanner.php file its getting error related with private function. private function includeClass(string $className, string $fileItemPath): bool { if (!class_exists($className)) { // phpcs:ignore require_once $fileItemPath; return true; } return false; }
So I remove the function and write the code directly called function. But I have seen same error is getting at compile time which define at private function. private function extract(\RecursiveIteratorIterator $recursiveIterator)
After that didnt get any solution then downgrade the PHP version 8.1 to 7.4. But this time again getting following error. PHP Fatal error: Uncaught Error: Call to undefined function Symfony\Component\Console\mb_detect_encoding() in /usr/share/php/Symfony/Component/Console/Application.php:1146 Stack trace: #0 /usr/share/php/Symfony/Component/Console/Application.php(806): Symfony\Component\Console\Application->splitStringByWidth() #1 /usr/share/php/Symfony/Component/Console/Application.php(776): Symfony\Component\Console\Application->doRenderException() #2 /usr/share/php/Symfony/Component/Console/Application.php(132): Symfony\Component\Console\Application->renderException() #3 /usr/share/php/Symfony/Component/Console/Application.php(155): Symfony\Component\Console\Application->Symfony\Component\Console{closure}() #4 /usr/share/php/Composer/Console/Application.php(113): Symfony\Component\Console\Application->run() #5 /usr/bin/composer(62): Composer\Console\Application->run() #6 {main} thrown in /usr/share/php/Symfony/Component/Console/Application.php on line 1146