Visual Studio代码PHP验证错误:无法验证,因为/ usr / bin / php不是有效的php可执行文件

问题描述 投票:-1回答:1

我正在尝试在Linux Mint 19中运行的Visual Studio Code中设置PHP验证。我添加了PHP executablePath,如here所述。我究竟做错了什么?

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

PHP信息:

$ which php
/usr/bin/php

$ php -v
PHP 7.3.3-1+ubuntu18.04.1+deb.sury.org+1 (cli) 
(built: Mar  7 2019 20:31:49) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.3, 
Copyright (c) 1998-2018 Zend Technologies 
with Zend OPcache v7.3.3-1+ubuntu18.04.1+deb.sury.org+1, 
Copyright (c) 1999-2018, by Zend Technologies

系统信息:

Operating System: Linux Mint 19 Cinnamon
Cinnamon Version: 3.8.9
Linux Kernel:     4.15.0-20-generic
php validation visual-studio-code mint
1个回答
1
投票

我刚刚发现了一个关于Visual Studio Code的权限问题。它尝试执行PHP但无法访问它,并且不会提供与此问题相关的错误。您只需将可执行文件复制到主文件夹即可。

sudo cp /usr/bin/php /home/$USER/php

之后,您可以将此行添加到settings.json

"php.validate.executablePath": "/home/<your-user-name>/php"
© www.soinside.com 2019 - 2024. All rights reserved.