r/PHPhelp • u/sampzadaa • Mar 02 '23
Solved Help for error with PHP executablePath in VSCode
I have a LAMP environment (Arch Linux, Apache, MariaDB, PHP). All updated and in the latest versions
I use VS Code to develop in this environment, however when using extensions like PHP Debug or PHP intelephense I get errors saying "Cannot validate because /usr/bin/php/ is not a valid php executable. Use the 'php. valid.executablePath' to configure the PHP executable."
The configuration is correct, in my terminal I ran which php to check and the return is the path defined in my configuration
"php.validate.executablePath": "/usr/bin/php/",
"php.debug.executablePath": "/usr/bin/php/", Additional informationWhen I run XDebug I get the following error in my terminal
Error: spawn usr/bin/php/ ENOENT
at ChildProcess._handle.onexit (node:internal/child_process:283:19)
at onErrorNT (node:internal/child_process:478:16)
at process.processTicksAndRejections (node:internal/process/task_queues:83:21) {
errno: -2,
code: 'ENOENT',
syscall: 'spawn usr/bin/php/',
path: 'usr/bin/php/',
spawnargs: [
'-dxdebug.start_with_request=yes',
'/srv/http/app/Controllers/AppController.php'
]
}I would like your help to solve this problem.
1
u/sampzadaa Mar 09 '23
After many attempts I managed to find the solution.
The truth is that the problem was not related to PHP or anything like that, but with the way I installed the IDEs (PHPStorm and VSCode)
I installed it using Flathub through an automatic installer that comes bundled with gnome.
The problem is that this installer cannot provide enough permissions for the IDEs, causing them not to be able to see the directories and executables that depend on special permissions.
I greatly appreciate everyone's help.
In case others need it, the best way forward is to install the IDEs through snapd, after that you can configure and use your editors normally
Obs. ignore that I promoted VSCode to IDE 
1
u/kAlvaro Mar 02 '23 edited Mar 03 '23
php.validate.executablePath is meant to be the file, not the directory. You don't need that anyway. As per the PHP Intelephense Quick Start instructions, you need to disable the builtin extension. It doesn't add any value and can cause duplicate suggestions.
With php.debug.executablePath, the problem is probably the same. Be aware that you only need it to debug command-line scripts while starting execution from the editor.
Consider adding php to your PATH so you don't need to specify paths in every tool.
1
u/jonnyclueless Mar 03 '23
At the CLI I ususally use 'which php' to find the path. With things like Homebrew it's not in the usual /usr/local/bin.
1
u/villanajith18 Jan 19 '24
{
"liveServer.settings.donotShowInfoMsg": true,
"redhat.telemetry.enabled": true,
"[php]": {
"editor.defaultFormatter": "bmewburn.vscode-intelephense-client"
},
"php.debug.executablePath": "/usr/bin/php/"
}
5
u/allen_jb Mar 02 '23
Are you sure it's not
/usr/bin/php- without a trailing/?The trailing
/usually indicates the path given is a directory. For a path to an (executable) file, there shouldn't be a trailing/.