Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

soheila-s's avatar

Laravel 9.48.0 + PHP 8.1.6 in VSCode shows syntax error

i have win10 in cmd.exe with composer create project: composer create-project laravel/laravel firstproject or (laravel new firstproject)

then: php artisan serve

but in vscode i have some syntax error in vendor folder

list of errors:

Syntax error:unexpected token 'string' php(php2014) Syntax error:unexpected token 'array' php(php2014) ...

in AppData\Roaming\Code\User\setting.json "intelephense.environment.phpVersion": "8.1.6"

how can i fix errors?

0 likes
3 replies
jlrdw's avatar

Check and see if something in your code requires a higher php version than you have.

Just a suggestion. Php has a wiki with changes.

sandrocagara's avatar

Go to settings, search for 'php version'.

Step 1: Find Intelephense > Environment: PHP Version then set it to what PHP version you have, ex:(8.2.0).

Step 2: Edit your settings.json

"php.executables": {
      "v8.2.0" :  "/xampp/php" 
},
 "php.version": "v8.2.0"

Step 3: Find PHP: Version then set it to v8.2.0 same with key that you provide in settings.json > php.executables

1 like

Please or to participate in this conversation.