php - 在 Ubuntu 的 VS Code 中设置 PHP 可执行路径
问题描述
版本:
- 操作系统
lsb_release -a
:Ubuntu 20.04.2 LTS - PHP 英特尔:1.6.2
- PHP
php -v
: 8.0.1 - 拉拉维尔:8.25
错误:
得到
Unexpected 'Unknown'
,';' expected.
,'VariableName' expected.
错误。
这些行导致错误
namespace App\Http\Controllers; //Unexpected 'Unknown' and ';' expected Error
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Auth;
在这里,我的错误截图:
试过了
我已经添加了 PHP 可执行路径VS Code 文章。但仍然无法正常工作
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
settings.json
{
"php.validate.executablePath": "usr\\bin\\php"
}
给我以下消息
无法验证,因为 usr\bin\php 不是有效的 php 可执行文件。使用设置 'php.validate.executablePath' 来配置 PHP 可执行文件。
谢谢。
解决方案
我用这个可执行路径解决了在 VS Code 中配置 PHP 可执行文件:
{
"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
推荐阅读
- amazon-web-services - 如何在放大项目中为不同的环境添加不同的身份验证?
- javascript - 如何使用属性合并两个数组?
- windows-kernel - NDIS LWF 驱动程序导致网络堆栈中的 WFP 驱动程序出现问题?
- reactjs - npm run build 不接受更改
- django - DRF 没有像预期的那样重新评估查询集
- javascript - 使用传单显示 OpenWeatherMap 的问题
- html - fullpage js 最后一节滚动销毁
- javascript - 未捕获的类型错误:无法读取 null 的属性(读取“vlaue”)
- wso2 - WSO2。Groovy 脚本 - 中的 JSON 有效负载无效
在第 1 行 - android - 为什么在 Fragment 的布局中,app:drawableXXXCompat 和 app:tintm app:xxxTint 不适用于 TextView 和 Images,但在 Activity 布局中效果很好?