Setting up VSCode: Difference between revisions
Marcus Green (talk | contribs) |
Marcus Green (talk | contribs) |
||
Line 42: | Line 42: | ||
This may be a good alternative | This may be a good alternative | ||
https://marketplace.visualstudio.com/items?itemName=ikappas.phpcs | https://marketplace.visualstudio.com/items?itemName=ikappas.phpcs | ||
Revision as of 20:15, 4 November 2020
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.
PHP Linting
https://docs.moodle.org/dev/Linting#Visual_Studio_Code
Moodle specific Snippets and autocomplete (plugin)
https://marketplace.visualstudio.com/items?itemName=MateuszLesiak.vscode-moodle-snippets
Offers some useful Moodle specific code completion popups.
Code Formatting (indentation)
https://marketplace.visualstudio.com/items?itemName=kokororin.vscode-phpfmt
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)
For this to work your instance of phpcs needs to have the moodle coding standards installed.
This link may help
https://askubuntu.com/questions/572956/adding-a-standard-to-php-codesniffer
You can check if it is installed from the command line with
phpcs -i
If it is installed moodle will show up in the output, here is a typcial example, note moodle is listed as the last but one item.
The installed coding standards are PEAR, PHPCS, Zend, PSR2, MySource, Squiz, PSR1, moodle and PHPCompatibility
This plugin will show a wavy red line under code that does not conform.
https://marketplace.visualstudio.com/items?itemName=wongjn.php-sniffer
This may be a good alternative
https://marketplace.visualstudio.com/items?itemName=ikappas.phpcs
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
Generate PHP Doc blocks
Type /** at the top of the function and it grabs the parameters, including types if given and creates a PHPDoc block
https://marketplace.visualstudio.com/items?itemName=neilbrayfield.php-docblocker
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.