I'm using php version 7.4 but I'm always getting the following item:
syntax error, unexpected '|', expecting variable (T_VARIABLE)
I am running command "php artisan serve --port9091" and in console.log it is showing that I am using php7.4 version as below:
Laravel development server started: http://127.0.0.1:9091
Cannot load Xdebug - it was already loaded
[Tue Oct 18 11:04:12 2022] PHP 7.4.30 Development Server (http://127.0.0.1:9091) started
[Tue Oct 18 11:04:16 2022] 127.0.0.1:65078 Accepted
[Tue Oct 18 11:04:17 2022] 127.0.0.1:65078 Closing
[Tue Oct 18 11:04:17 2022] 127.0.0.1:65079 Accepted
[Tue Oct 18 11:04:17 2022] PHP Parse error: syntax error, unexpected '|', expecting variable (T_VARIABLE) in /mnt/c/mt/web-v3/vendor/psr/log/src/LoggerInterface.php on line 30
If you notice it is saying the error I mentioned above, I've already seen that this is referring to the PHP version, but as I said and in the text above I'm using the 7.4 version, what have I done?
- deleted vendor folder
- composer install
- composer update
And the error persists.
My composer version is 2.4.3
For a better example I'm putting my composer.json below as well.
{
"name": "october/october",
"description": "OctoberCMS",
"homepage": "https://octobercms.com",
"type": "project",
"keywords": ["october", "cms", "octobercms", "laravel"],
"license": "MIT",
"authors": [
{
"name": "Alexey Bobkov",
"email": "[email protected]",
"role": "Co-founder"
},
{
"name": "Samuel Georges",
"email": "[email protected]",
"role": "Co-founder"
},
{
"name": "Luke Towers",
"email": "[email protected]",
"homepage": "https://luketowers.ca",
"role": "Maintainer"
}
],
"support": {
"issues": "https://github.com/octobercms/october/issues",
"forum": "https://octobercms.com/forum/",
"docs": "https://octobercms.com/docs/",
"irc": "irc://irc.freenode.net/october",
"source": "https://github.com/octobercms/october"
},
"require": {
"php": ">=7.3",
"ext-mbstring": "*",
"ext-openssl": "*",
"winter/storm": "~1.1.2",
"winter/wn-system-module": "~1.1.2",
"winter/wn-backend-module": "~1.1.2",
"winter/wn-cms-module": "~1.1.2",
"laravel/framework": "~6.0",
"wikimedia/composer-merge-plugin": "1.4.1",
"barryvdh/laravel-dompdf": "^0.8.6",
"phpoffice/phpspreadsheet": "^1.8",
"kreait/firebase-php": "^4.44"
},
"require-dev": {
"fzaninotto/faker": "~1.7",
"phpunit/phpunit": "~6.5",
"phpunit/phpunit-selenium": "~1.2",
"meyfa/phpunit-assert-gd": "1.1.0",
"squizlabs/php_codesniffer": "3.*",
"jakub-onderka/php-parallel-lint": "^1.0"
},
"autoload-dev": {
"classmap": [
"tests/concerns/InteractsWithAuthentication.php",
"tests/fixtures/backend/models/UserFixture.php",
"tests/TestCase.php",
"tests/UiTestCase.php",
"tests/PluginTestCase.php"
]
},
"scripts": {
"post-create-project-cmd": [
"php artisan key:generate",
"php artisan package:discover"
],
"post-update-cmd": [
"php artisan winter:version",
"php artisan package:discover"
]
},
"config": {
"preferred-install": "dist",
"platform": {
"php": "7.3"
},
"allow-plugins": {
"composer/installers": true
}
},
"minimum-stability": "dev",
"prefer-stable": true,
"extra": {
"merge-plugin": {
"include": [
"plugins/*/*/composer.json"
],
"recurse": true,
"replace": false,
"merge-dev": false
}
}
}
CodePudding user response:
I believe this is because of your php version. update your composer.josn
and type the correct php version.
"config": {
"platform": {
"php": "your php version"
}
}
and run composer update or composer install.
CodePudding user response:
it may cause many other things this error will occur.
For laravel, delete the vendor folder, and the composer.lock file and then run composer install. it worked for me
reference https://github.com/Seldaek/monolog/issues/1597#issuecomment-1004582136