Visual Studio Code

My favorite feature so far is in the form of an extension. The vscode-php-debug extension works better than any free PHP debugging solution I have tried, such as Eclipse, Netbeans or SublimeTextXdebug. In order to use the debugger, the Xdebug PHP extension will need to be installed for your version of PHP. Here are some Xdebug installation resources:

User Settings

My VS Code user preferences – I changed the default, "workbench.editor.enablePreview": true – When this is set to true, a subsequent file open will close the previous file if it has not been double clicked or edited. I wanted to keep the files open, so I set this to false.

settings.json
// Place your settings in this file to overwrite the default settings
{
  "editor.renderWhitespace": "all",
  "editor.fontFamily": "Fira Code Retina Medium",
  "editor.fontLigatures": true,
  "editor.fontSize": 13,
  "editor.lineHeight": 22,
  "editor.minimap.enabled": false,

  // Configure glob patterns for excluding files and folders.
  // "files.exclude": {
  //   "**/node_modules": true
  // },

  "files.trimTrailingWhitespace": true,

  // "git.enabled": false,

  "gitlens.advanced.messages": {
    "suppressShowKeyBindingsNotice": true
  },

  "vsicons.projectDetection.disableDetect": true,

  "window.zoomLevel": 0,

  "workbench.editor.enablePreview": false,

  "workbench.iconTheme": "vscode-icons",
  // "workbench.iconTheme": "vs-seti",

  "workbench.activityBar.visible": true,
  "workbench.sideBar.location": "left",

  //// Command Prompt
  // "terminal.integrated.shell.windows": "C:\\Windows\\System32\\cmd.exe"
  //// PowerShell
  //"terminal.integrated.shell.windows": "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe"
  //// Git Bash
  // "terminal.integrated.shell.windows": "C:\\Program Files\\Git\\bin\\bash.exe"
  //// Bash on Ubuntu (on Windows)
  "terminal.integrated.shell.windows": "C:\\Windows\\System32\\bash.exe",
  "terminal.integrated.shellArgs.windows": ["-c", "zsh"]
  //// Cygwin
  // "terminal.integrated.shell.windows": "C:\\Cygwin\\bin\\bash.exe",
  //// Cygwin ZSH
  // "terminal.integrated.shell.windows": "C:\\Cygwin\\bin\\zsh.exe",
  // "terminal.integrated.shellArgs.windows": [
  //  "-lic",
  //  "cd $OLDPWD; exec bash"
  // ],
}

Workspace Settings

You can also create specific settings for a saved workspace. e.g.,

doc.code-workspace
{
    "folders": [
        {
            "path": "doc"
        }
    ],
    "settings": {
        "workbench.colorTheme": "Solarized Light"
    }
}

Extensions

Here is a list of my favorite VS Code extensions

PHP Debug

Remote debugging with xdebug – As noted in the Remote Host Debugging section, To make VS Code map the files on the server to the local machine, add the serverSourceRoot and localSourceRoot settings in the project .vscode/launch.json file. For example,

launch.json
{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Listen for XDebug",
            "type": "php",
            "request": "launch",
            "port": 9000,
            "serverSourceRoot": "/var/www/html",
            "localSourceRoot": "${workspaceRoot}"
        },
        {
            "name": "Launch currently open script",
            "type": "php",
            "request": "launch",
            "program": "${file}",
            "cwd": "${fileDirname}",
            "port": 9000
        }
    ]
}

Java

With these extensions, it is possible to use use Visual Studio Code for Java Development instead of Eclipse or NetBeans.


Resources