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?
2 Answers 2
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.
Just in case someone else comes across this, it was solved by changing the default version of php to the latest one in plesk
For example, my system php is 5.5:
$ php -v
PHP 5.5.9-1ubuntu4.11 (cli) (built: Jul 2 2015 15:23:08)
$ which php
/usr/bin/php
But I want to use php 5.6 installed by Plesk:
$ /opt/plesk/php/5.6/bin/php -v
PHP 5.6.13 (cli) (built: Sep 8 2015 11:53:39)
$ export PATH=/opt/plesk/php/5.6/bin:$PATH
$ php -v
PHP 5.6.13 (cli) (built: Sep 8 2015 11:53:39)
$ which php
/opt/plesk/php/5.6/bin/php
Bootstrap.phpon line 411? In the latest version on github there is this github.com/magento/magento2/blob/develop/lib/internal/Magento/… which does not make much sense.