Parse error: syntax error, unexpected '|', expecting variable (T_VARIABLE) Symfony PHP VERSION WAMP Windows
10,257
I added this in the composer.json and it worked.
"config": {
"platform": {
"php": "7.4.21"
}
}
The run. composer update
This downgraded psr/log to a lower version from 2.0 and resolved my issue.
Author by
akali leona
Updated on June 04, 2022Comments
-
akali leona almost 2 years
I have some syntax errors from symfony vendor when i'm trying to composer install my project.
Parse error: syntax error, unexpected '|', expecting variable (T_VARIABLE) vendor\psr\log\src\LoggerInterface.php on line 30
With several search, I saw the problem is from PHP version (have to be > 7.1), but actually my version is 7.4.9, this is a local machine, i'm working with WAMP on Windows. Symfony 4.4 version. Already tried to delete vendor, .lock...
Here the php version from phpinfo()
Here php version from CLI php-v
Here my composer.json
{ "type": "project", "license": "proprietary", "require": { "php": ">=7.1.3", "ext-ctype": "*", "ext-iconv": "*", "doctrine/annotations": "^1.13", "mongodb/mongodb": "^1.10@dev", "ramsey/uuid": "^4.2", "symfony/console": "4.4.*", "symfony/dotenv": "4.4.*", "symfony/flex": "^1.3.1", "symfony/form": "4.4.*", "symfony/framework-bundle": "4.4.*", "symfony/messenger": "4.4.*", "symfony/yaml": "4.4.*" }, "require-dev": { }, "minimum-stability": "dev", "config": { "preferred-install": { "*": "dist" }, "sort-packages": true, "platform": { "php": "7.4.9" } }, "autoload": { "psr-4": { "App\\": "src/" } }, "autoload-dev": { "psr-4": { "App\\Tests\\": "tests/" } }, "replace": { "paragonie/random_compat": "2.*", "symfony/polyfill-ctype": "*", "symfony/polyfill-iconv": "*", "symfony/polyfill-php71": "*", "symfony/polyfill-php70": "*", "symfony/polyfill-php56": "*" }, "scripts": { "auto-scripts": { "cache:clear": "symfony-cmd", "assets:install %PUBLIC_DIR%": "symfony-cmd" }, "post-install-cmd": [ "@auto-scripts" ], "post-update-cmd": [ "@auto-scripts" ] }, "conflict": { "symfony/symfony": "*" }, "extra": { "symfony": { "allow-contrib": false, "require": "4.4.*" } } }
Have some idea ?
-
Álvaro González over 2 yearsYou seemingly have latest version installed, which uses PHP/8 syntax (you can check that with e.g.
composer info psr/log
). Either it's ignoring your"platform"
settings for some reason, of you made changes but didn't update. Do you have acomposer.lock
file coming from the repository? Doescomposer update
change something? -
Anuga over 2 yearsHow does
vendor\psr\log\src\LoggerInterface.php on line 30
look like, it is not accepting several parameters obviously, so there is a version issue with either the package or php.
-
-
Álvaro González over 2 yearsIt's worth noting that the settings on the question already include a similar
platform
settings. It's possible that the OP didn't refresh withcomposer update
or they had another issue. -
Radon8472 about 2 yearsThx that saved my day. But note that you may have to re-install your libs (yust delete composer.lock and composer/installed.json and run
composer update
) to make this taking affect -
oligofren almost 2 yearsThis was it! I globally had PHP 7.4 (used by phpunit), but running in IntelliJ used the PHP 8.1 runner.