I noticed that in Visual Studio Code there is a menu item called "Start Without Debugging" under the "Debug" menu. When I have a PHP file open, I expected this to run the PHP file through the PHP executable and give me the output. Instead, when I click on "Start Without Debugging", the User Settings page shows up. Why does the User Settings page show up? It's not clear why this page is presented to me. Does it want me to configure something? How do I get it to just run the PHP file that I have open through the PHP executable. Is this even possible?
I noticed in the Default Settings there is a property called "php.validate.executablePath"
that is set to null
. I tried overriding this setting in my User Settings by pointing it to the path of my PHP executable like this:
{
"php.validate.executablePath": "/usr/bin/php"
}
But that didn't solve anything. The User Settings page still shows up when I click "Start Without Debugging".
Go to File->Preferences->settings->User settings tab->extensions->from the drop down select php->on the right pane under PHP › Validate: Executable Path select edit in settings.
You can search for PHP extensions from within VS Code in the Extensions view (Ctrl+Shift+X) then filter the extensions dropdown list by typing 'php'.
Workspace settings are specific to a project and can be shared across developers on a project. Workspace settings override user settings. Note: A VS Code "workspace" is usually just your project root folder.
After doing more research, I found the solution to my problem. Based on this section in the vscode docs and this comment that mentions creating a global launch configuration, all you have to do is add a launch
object to your User Settings JSON.
In my case, I added this to my User Settings:
"launch": {
"version": "0.2.0",
"configurations": [
{
"type": "php",
"request": "launch",
"name": "Launch Program",
"program": "${file}",
"runtimeExecutable": "/usr/bin/php"
}
]
}
Your value for runtimeExecutable
may be different depending on the path to your PHP executable.
I ran in to the same issue except I was trying to run a C++ file (doing all this in Windows 11). I followed the instructions here, which said that I needed to run VSCode from within a "developer terminal" (which is able to run cl, the command for the MSVC C++ compiler).
At first, I did so and it still did not work (I'm absolutely sure of this). But then I tried again and it worked; I was able to run and debug a hello.cpp. Not exactly sure what happened, maybe it needed time to "warm up" or something (which would be awful if true).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With