Note:

If you want to create a new page for developers, you should create it on the Moodle Developer Resource site.

Setting up VSCode

From MoodleDocs
Revision as of 10:51, 25 February 2020 by Marcus Green (talk | contribs)

VSCode stub https://en.wikipedia.org/wiki/Visual_Studio_Code

VSCode is a an Integrated Development Environment from Microsoft available under the MIT License. It works on Linux/Windows/OSX. It has a large number of plugins available, most entirely free/libre. It has good support for Xdebug.

Moodle specific Snippets and autocomplete (plugin)

https://marketplace.visualstudio.com/items?itemName=MateuszLesiak.vscode-moodle-snippets

Offers some useful Moodle specific code completion popups.

Show coding standards issues (plugin)

If you have Code Sniffer set up https://github.com/squizlabs/PHP_CodeSniffer/blob/master/src/Sniffs/Sniff.php (or https://github.com/moodlehq/moodle-local_codechecker) This plugin will show a wavy red line under code that does not conform. https://github.com/wongjn/vscode-php-sniffer

Run phpunit tests from within IDE (plugin)

https://marketplace.visualstudio.com/items?itemName=danilopolani.yet-another-phpunit

A file of unit tests or individual test can be run from within the IDE

Auto trim trailing white space

To ensure trailing white space is trimmed do the following

Open VS User Settings (Preferences > Settings > User Settings tab). Click the {} icon in the top-right part of the window. This will open a document.

Add a new "files.trimTrailingWhitespace": true setting to the User Settings document if it's not already there. This is so you aren't editing the Default Setting directly, but instead adding to it.

Save the User Settings file.