Magento – Magento 2.1.2 – PHP Parse Error in Bootstrap.php when trying to execute bin/magento commands

bin-magentoPHPssh

Can't seem to find a fix for this issue. I'm running Magento 2.1.2 with PHP 7.0.16, however there are different versions of PHP installed on different websites on the same VPS.

When trying to execute magento/bin commands, it seems to throw the same error with any – however the most recent I've tried is:

 php bin/magento setup:static-content:deploy

It throws the following errors:

PHP Warning: Cannot open '/usr/lib64/php/modules/php_browscap.ini' for reading in Unknown on line 0
PHP Parse error: syntax error, unexpected 'class' (T_CLASS), expecting identifier (T_STRING) or variable (T_VARIABLE) or '{' or '$' in ***/httpdocs/vendor/magento/framework/App/Bootstrap.php on line 411

The function which includes line 411 is as follows, with the problem line surrounded by **:

public function isDeveloperMode()
{
    $mode = 'default';
    if (isset($this->server[State::PARAM_MODE])) {
        $mode = $this->server[State::PARAM_MODE];
    } else {
     ** $deploymentConfig = $this->getObjectManager()->get(DeploymentConfig::class); **
        $configMode = $deploymentConfig->get(State::PARAM_MODE);
        if ($configMode) {
            $mode = $configMode;
        }
    }

    return $mode == State::MODE_DEVELOPER;
}

The only details I can find online relate to there being an incompatible installation of PHP, but that shouldn't be an issue as I'm running 7.0.16?

Best Answer

Turned out to be an issue with multiple versions of PHP being installed on the same VPS and running Plesk. Setting up an independent VPS only running PHP 7.0.16 fixed the errors.