I'm using Visual Studio Code for different web development. Recently I'm using Drupal 8 to develop new websites. Drupal 8 has some theme file to place some PHP code in it to changes some parts of theming. How can I debug this theme files in Visual Studio Code? I can't place any breakpoints in my code.
-
Found the answer in another StackOverflow thread: http://stackoverflow.com/questions/29973619/how-to-make-vs-code-to-treat-other-file-extensions-as-certain-language – JimmyD Nov 26 '16 at 08:30
2 Answers
If you find yourself here in future, you might want to look at Drupal Configuring for Visual Studio Code available on drupal site docs. The URL is: https://www.drupal.org/docs/develop/development-tools/configuring-visual-studio-code
It explans in depth how you can configure:
- phpcs: provides integration for PHP CodeSniffer (phpcs) code linting.
- Debugger for Chrome: is a Microsoft official extension that adds JavaScript debugging support.
- PHP DocBlocker: provides auto-complete for PHP docblocks.
- Empty Indent: removes indent of empty lines on save.
- PHP Debug: provides launch configuration support for XDebug. Requires XDebug.
- And most important Editor Settings.
Happy coding

- 2,897
- 2
- 20
- 19
If you want to use Drupal with vscode I suggest you to install VS-code-drupal extension. It makes .module
files recognizable as php files.
If you want to debug php code I suggest you to install vscode-php-debug extension. It's a bit tricky to configure, but if you follow the guide you will succeed.
Another useful extension is vscode-code-runner. It runs portions of code for testing it on the fly.
Unfortunately I have not found yet a good extension for php intellisense.

- 1,678
- 20
- 32