-1

Version:

  • OS lsb_release -a : Ubuntu 20.04.2 LTS
  • PHP Intelephense: 1.6.2
  • PHP php -v : 8.0.1
  • Laravel: 8.25

Error:

Getting Unexpected 'Unknown', ';' expected., 'VariableName' expected. error.

These kind of lines are causing error

namespace App\Http\Controllers; //Unexpected 'Unknown' and ';' expected Error

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Auth;

Here, Screenshot of my error:

enter image description here


Tried

I've have added PHP executable path VS Code article. But still not working

settings.json

{
    "php.validate.executablePath": "/usr/bin/php"
}

$ whereis php

php: /usr/bin/php8.0 /usr/bin/php.default /usr/bin/php /usr/lib/php 
/etc/php /usr/share/php8.0-mysql /usr/share/php8.0-readline 
/usr/share/php8.0-common /usr/share/php8.0-zip /usr/share/php8.0-xml 
/usr/share/php8.0-bz2 /usr/share/php /usr/share/php7.1-common 
/usr/share/php8.0-opcache /usr/share/php8.0-mbstring /usr/share/php8.0-gd 
/usr/share/php7.1-mcrypt /usr/share/php8.0-curl /opt/lampp/bin/php 
/usr/share/man/man1/php.1.gz

$ which php

/usr/bin/php

Adding Backslash

settings.json

{
    "php.validate.executablePath": "usr\\bin\\php"
}

Giving me following message

Cannot validate since usr\bin\php is not a valid php executable. Use the setting 'php.validate.executablePath' to configure the PHP executable.


Thanks.

Sakura Kinomoto
  • 1,784
  • 2
  • 21
  • 30
Maqsud
  • 739
  • 3
  • 12
  • 35

1 Answers1

-1

I resolved with this executable path to configure the PHP executable in VS Code:

    {
    "php.validate.executablePath": "/usr/bin/php8.1"
    }

    whereis php
    php: /usr/bin/php /usr/bin/php8.1 /usr/lib/php /etc/php
       /usr/share/php /usr/share/php8.1-bcmath /usr/share/php8.1-xml /usr/share
    /php8.1-readline /usr/share/php8.1-zip /usr/share/php8.1-mysql /usr/share
    /php8.1-ldap /usr/share/php8.1-mbstring /usr/share/php8.1-common /usr/share
    /php8.1-intl /usr/share/php8.1-bz2 /usr/share/php8.1-gd /usr/share/php8.1-
    pgsql /usr/share/php8.1-curl /usr/share/php8.1-soap /usr/share/php8.1-opcache
     /usr/share/man/man1/php.1.gz
  • 1
    It helps more if you supply an explanation why this is the preferred solution and explain how it works. We want to educate, not just provide code. Please go through the [Stack Overflow tour](https://stackoverflow.com/tour). – the Tin Man Jan 21 '22 at 23:52