php.debug.executablePath in docker
VS Code extension version: v1.34.0
How do i specify php executable path in docker container?:
settings.json
{
"php.debug.executablePath": "???",
}
Depends on how you have your environment setup. How would you run your script from command line? Let's say it's something like this:
docker exec mycontianer php /app/script.php
There are a bunch of launch.json variables there are used to run a program:
runtimeExecutable runtimeArgs program args
So for this case you would have something like this:
{
"request":"launch",
...
"runtimeExecutable": "docker",
"runtimeArgs": [
"exec",
"mycontainer",
"php"
],
"program": "${fileBasename}",
}
There area few considerations regarding path mappings, but without some info about your setup I can not give specific examples.
@zobo thanks for your reply. I see that it is related to launch.json, but I specifically asked about option in settings.json.
Just a note: my launch.json is already working both in browser and console for debugging, however some of the extension functionality seems to be using that parameter php.debug.executablePath for validation or something, and I keep getting an error message couldnt validate because php is not found.
Ah sorry, I didn't pay enough attention, but also, this isn't related to this extension then. Can you figure out first which extension reports the error?
@zobo actually, i was quite sure this prefix is always pointing to the extension.
So in php.debug.executablePath php.debug is the extension, and executablePath is its variable.
Would you please double check? I think this should be reproducible when you dont have php installed on host machine at all.
You are right, I'm very sorry, this is what I get for trying to answer tickets after a whole day on the road.
Indeed the only extension that should be using php.debug.executablePath setting should be this extension. VS Code is made so that only one extension can register a setting - however in theory, multiple extensions could be using it.
The only place this setting is used is for "auto filling" launch.json. https://github.com/xdebug/vscode-php-debug/blob/main/src/extension.ts#L42
When a debug session is started and program is set, the debugger tries to start by executing what is in launch.json executablePath. If it is not set, it tries the php.debug.executablePath setting and then falls back to just php in the path.
Maybe another thing I should try to explain; This extension provides php debugging only. No auto complete, no validation, just debugging. Other extensions are responsible for that. To get "language support" you can look at https://marketplace.visualstudio.com/items?itemName=phpactor.vscode-phpactor or https://marketplace.visualstudio.com/items?itemName=zobo.php-intellisense (but I don't really have time to maintain this one anymore).
There are other options like https://marketplace.visualstudio.com/items?itemName=bmewburn.vscode-intelephense-client and devsense (this one offers all php tools as one extension and conflicts with a bunch of others) both a free/commercial combination.
There is also some basic validation built in vscode that uses php and probably complains if it cannot be found. See https://code.visualstudio.com/docs/languages/php (php.validate.executablePath setting).
Here is another suggestion. If you are developing in docker containers, look at VSCode Remote Containers. https://code.visualstudio.com/docs/devcontainers/containers This is the best possible experience. Your vscode lives inside the container and has direct access to php and the source files.