skip to Main Content

After upgrading to magento 2.4.5-p1 and to php 8.1

I get this error while I try to compile

I tried to delete the vendor folder and did composer update but same results.

any way to solve this issue?

public_html$ bin/magento setup:di:compile
Compilation was started.
Repositories code generation... 1/9 [===>------------------------]  11% < 1 sec 115.0 MiBsyntax error, unexpected token "readonly", expecting identifier#0 /home/0.cloudwaysapps.com/bmd/public_html/setup/src/Magento/Setup/Module/Di/Code/Reader/ClassesScanner.php(117): MagentoSetupModuleDiCodeReaderClassesScanner->includeClass()
#1 /home/0.cloudwaysapps.com/bmd/public_html/setup/src/Magento/Setup/Module/Di/Code/Reader/ClassesScanner.php(87): MagentoSetupModuleDiCodeReaderClassesScanner->extract()
#2 /home/0.cloudwaysapps.com/bmd/public_html/setup/src/Magento/Setup/Module/Di/App/Task/Operation/RepositoryGenerator.php(61): MagentoSetupModuleDiCodeReaderClassesScanner->getList()
#3 /home/0.cloudwaysapps.com/bmd/public_html/setup/src/Magento/Setup/Module/Di/App/Task/Manager.php(56): MagentoSetupModuleDiAppTaskOperationRepositoryGenerator->doOperation()
#4 /home/0.cloudwaysapps.com/bmd/public_html/setup/src/Magento/Setup/Console/Command/DiCompileCommand.php(216): MagentoSetupModuleDiAppTaskManager->process()
#5 /home/0.cloudwaysapps.com/bmd/public_html/vendor/symfony/console/Command/Command.php(255): MagentoSetupConsoleCommandDiCompileCommand->execute()
#6 /home/0.cloudwaysapps.com/bmd/public_html/vendor/symfony/console/Application.php(1021): SymfonyComponentConsoleCommandCommand->run()
#7 /home/0.cloudwaysapps.com/bmd/public_html/vendor/symfony/console/Application.php(275): SymfonyComponentConsoleApplication->doRunCommand()
#8 /home/0.cloudwaysapps.com/bmd/public_html/vendor/magento/framework/Console/Cli.php(116): SymfonyComponentConsoleApplication->doRun()
#9 /home/0.cloudwaysapps.com/bmd/public_html/vendor/symfony/console/Application.php(149): MagentoFrameworkConsoleCli->doRun()
#10 /home/0.cloudwaysapps.com/bmd/public_html/bin/magento(23): SymfonyComponentConsoleApplication->run()
#11 {main}

Thanks alot

Kobi

2

Answers


  1. I’m from Cloudways Magento Community

    Need to reproduce the steps for resolving the issue:

    • Downgrade your PHP version and check if its works

    • It seems some of your extensions create conflict in it, so what you can do is launch another application with the latest version and deploy each of your extensions one by one. This will let you know what causes the conflicts.

    • Check file permissions: https://support.cloudways.com/en/articles/5126387-how-can-i-reset-file-and-folder-permissions

    • Check the class which has a readonly keyword because:
      readonly is a reserved keyword in PHP 8.1. Any existing classes or other symbols that use the name readonly (case insensitive) will result in a syntax error in PHP 8.1.

    It is not possible to port the readonly functionality to older PHP versions. However, the @readonly / @property-read annotations is understood by static analyzers such as Psalm.

    Thanks

    Login or Signup to reply.
  2. It seems like a syntax error in your code, please check the last code that you added before deployment.

    go to the Magento root folder and open the var/log folder, here you can check the log files, and you will find the error records here.

    after that run, all deployment commands with di: compile one by one.

    Thanks.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search