Upgrade 8.2.1 -> 8.2.2 PHP Parse error: syntax error, unexpected 'class' (T_CLASS)


I have problem while upgrading from 8.2.1 to 8.2.2. When I use the command:
./bin/console suitecrm:app:upgrade -t SuiteCRM-8.2.2

I get an error:
PHP Parse error: syntax error, unexpected ‘class’ (T_CLASS), expecting identifier (T_STRING) or variable (T_VARIABLE) or ‘{’ or ‘$’ in /home/…/bin/console on line 17

I found my problem to be similar to SuiteCRM 7.12.x migration to SuiteCRM 8.x syntax error, unexpected 'class' (T_CLASS)

I checked following.

Line 17 looks like this:

if (!class_exists(Application::class)) {
    throw new LogicException('You need to add "symfony/framework-bundle" as a Composer dependency.');

CLI PHP version is 8.0.21 (I tried 7.4 and 7.3 as well).

Is there anything else I can try/test? I would be grateful for any help.

As I understand this is the problem with PHP version. I got this response from GitHub developers.


according to the compatibility matrix 7.12.x is only supporting up to PHP8.0.

The roadmap is saying PHP8.2 support will be part of SuiteCRM-7.14 and 8.4.


But as I can see your server PHP version is ok?
I am personally waiting for PHP 8.2 to be supported in SuiteCRM.

Yes, it looks like a version problem but my server PHP version seems to be fine.

What do you get with this command:

php -V /version/

With PHP 8 version it’s:
PHP 8.0.21 (cli) (built: Jul 5 2022 09:25:04) ( NTS )
Copyright (c) The PHP Group
Zend Engine v4.0.21, Copyright (c) Zend Technologies
with Zend OPcache v8.0.21, Copyright (c), by Zend Technologies

That is the CLI version, the web server can be different.

You can find out in Admin / Diagnostics / phpinfo

Yes, it’s from CLI. Isn’t it the one that is important while running upgrade commands through CLI?
Server version is 7.4. It was 8.0 but I had to change it to 7.4 due to errors in email module.

You are correct, my apologies for not reading the posts correctly.

You now changed to PHP 7.4? With 7.4, do you still get the same error as above?

No problem.

I’ve changed server PHP version to 7.4. I’ve tried to upgrade through CLI with PHP versions 8.0, 7.4 and 7.3 - all resoulting with same error.

Does your file match this one, character by character?

As far as I can research, there are only two ways you can be seeing this error:

  • an old PHP version for some reason getting invoked
  • some syntactic problem a bit above the error line

EDIT: one more possibility!

  • some trouble inside the required file which precedes this line (require dirname(__DIR__) . '/vendor/autoload.php';)

Thank you. I’ll check that and will let you know about the results.

I’m sorry for the late response.

The file matched character by character. It occurred as you wrote that old PHP version was involved. It was some error on hosting site. They gave me another solution and it worked.

Thank you all for your time and help :slight_smile:

1 Like