Friday, March 23, 2018

Why does Visual Studio Code show User Settings instead of running a PHP file?

Leave a Comment

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".

1 Answers

Answers 1

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.

If You Enjoyed This, Take 5 Seconds To Share It

0 comments:

Post a Comment