Viewed   78 times

I can't find a way to run or debug php on Visual studio code, Does anyone know how?

 Answers

5

As far as I read about it today, you can't debug anything else than node.js, JavaScript and TypeScript at the moment, but they said they want to add new languages which you can debug. The editor is still in development. Nevertheless, I don't think there will be a php debugger in the future since php is serverside, so you can't debug it on your client alone.

If you want to debug php, I can recommend xDebug.


Updated:

Now, it is possible to debug with VS code. You need to install XDebug and php-debug extension for VScode.

Friday, October 7, 2022
3

See Tyler Long's answer. The steps below are not required in the newest versions of Visual Studio Code :)


I made a repository to demonstrate.

First off, the only way I could get the debugger to hit the test was to add a file, Program.cs, take control of the entry point from xUnit, and manually add code to test. It's not ideal, but I imagine you aren't going to be doing this very often, and it's easy to flip it back to normal.

Program.cs:

using System;
namespace XUnitDebugging
{
    public class Program
    {
        public static void Main(string[] args)
        {
            var test = new TestClass();
            test.PassingTest();
            Console.WriteLine("Enter text...");
            Console.ReadLine();

        }
    }
}

Next, in project.json add the following:

  "buildOptions": {
    "emitEntryPoint": true,
    "debugType": "portable"
  },

project.json:

{
  "version": "1.0.0-*",
  "testRunner": "xunit",
  "buildOptions": {
    "emitEntryPoint": true,
    "debugType": "portable"
  },
  "dependencies": {
    "Microsoft.NETCore.App": {
      "type": "platform",
      "version": "1.0.0"
    },
    "xunit": "2.2.0-beta2-build3300",
    "dotnet-test-xunit": "2.2.0-preview2-build1029"
  },
  "frameworks": {
    "netcoreapp1.0": {
      "dependencies": {
        "Microsoft.NETCore.App": {
          "type": "platform",
          "version": "1.0.0"
        }
      }
    }
  }
}

This will allow you to debug an xUnit unit test project.

Tuesday, November 29, 2022
 
4

OK, I finally figured out what was the problem. There are two ways you can change the comment blocks:

1 - CONFIG FILE

I dont know why it's not in the docs (or at least I couldn't find it) but there is a optional property you pass to the object inside the contributes.languages array in the package.json named configuration.

The description found on the vs code source code:

A relative path to a file containing configuration options for the language.

On that files you can create an object like this one and it's gonna overwrite the default comment characters

{
  "comments": {
    "lineComment": "//",
    "blockComment": [ "<!--", "-->" ]
  }
}

You can see this properties on the API references: https://code.visualstudio.com/Docs/extensionAPI/vscode-api#CommentRule

Note: That comment block command is triggered with a different shortcut. You can overwrite it though (in a general or even for a specific language using the property when on the key binding object).

??A - Toggle Block Comment - editor.action.blockComment https://code.visualstudio.com/Docs/customization/keybindings

2 - "SYNTAX" FILE .tmLanguage

Yes, you can do it from there too and you can make it even better. You can see an example here https://github.com/andrejunges/vscode-handlebars/blob/master/syntaxes/handlebars.tmLanguage#L68

Tuesday, October 4, 2022
 
2

The answer is in this GitHub issue:

The current recommendation is to turn on word wrapping if the intent is to edit past the 10k limit or change the limit via the "hidden" setting "editor.stopRenderingLineAfter" which is equal to 10000 by default, but which can be changed to -1 to never stop rendering. But then freezes/lagging might occur.

In other words, use CTRL + SHIFT + P to open up the Command Palette, select Preferences: Open Settings (JSON), and add the following line:

"editor.stopRenderingLineAfter" : -1

If you want to set a hard limit just change the -1 to whatever number of characters you want. Note that you might still get wrapping happening if you haven't disabled it, which you can toggle with ALT + Z or using the other methods mentioned in this post.

Monday, August 8, 2022
 
1

I found a better solution, based on the previous ones:

Go to Workplace Settings. Override the parameter python.venvPath with the Path to folder with a list of Virtual Environments. For the case of anaconda:

This setting enables VS Code to recognize the available conda environments. Thus, we can click on the current python interpreter and switch to others:

Wednesday, October 5, 2022
 
wazner
 
Only authorized users can answer the search term. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :